diff options
author | Uri Simchoni <uri@jdland.co.il> | 2010-04-08 12:31:48 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-04-13 04:50:48 -0400 |
commit | f0d03deaad05d9cc99cd2ee0475c9ecd726c19ae (patch) | |
tree | df89583294ee0bfe790b874608182c51788b9bc0 /drivers/crypto/mv_cesa.c | |
parent | a58094ac5f95d6969e5c52ff096d2fd2864542af (diff) |
crypto: mv_cesa - Make the copy-back of data optional
Make the copy-back of data optional (not done in hashing requests)
Signed-off-by: Uri Simchoni <uri@jdland.co.il>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/mv_cesa.c')
-rw-r--r-- | drivers/crypto/mv_cesa.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 2b4f07aa89e8..49a22060fb51 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c | |||
@@ -40,6 +40,7 @@ enum engine_status { | |||
40 | * @src_start: offset to add to src start position (scatter list) | 40 | * @src_start: offset to add to src start position (scatter list) |
41 | * @crypt_len: length of current crypt process | 41 | * @crypt_len: length of current crypt process |
42 | * @hw_nbytes: total bytes to process in hw for this request | 42 | * @hw_nbytes: total bytes to process in hw for this request |
43 | * @copy_back: whether to copy data back (crypt) or not (hash) | ||
43 | * @sg_dst_left: bytes left dst to process in this scatter list | 44 | * @sg_dst_left: bytes left dst to process in this scatter list |
44 | * @dst_start: offset to add to dst start position (scatter list) | 45 | * @dst_start: offset to add to dst start position (scatter list) |
45 | * @hw_processed_bytes: number of bytes processed by hw (request). | 46 | * @hw_processed_bytes: number of bytes processed by hw (request). |
@@ -60,6 +61,7 @@ struct req_progress { | |||
60 | int crypt_len; | 61 | int crypt_len; |
61 | int hw_nbytes; | 62 | int hw_nbytes; |
62 | /* dst mostly */ | 63 | /* dst mostly */ |
64 | int copy_back; | ||
63 | int sg_dst_left; | 65 | int sg_dst_left; |
64 | int dst_start; | 66 | int dst_start; |
65 | int hw_processed_bytes; | 67 | int hw_processed_bytes; |
@@ -267,33 +269,35 @@ static void dequeue_complete_req(void) | |||
267 | struct crypto_async_request *req = cpg->cur_req; | 269 | struct crypto_async_request *req = cpg->cur_req; |
268 | void *buf; | 270 | void *buf; |
269 | int ret; | 271 | int ret; |
270 | int need_copy_len = cpg->p.crypt_len; | ||
271 | int sram_offset = 0; | ||
272 | |||
273 | cpg->p.hw_processed_bytes += cpg->p.crypt_len; | 272 | cpg->p.hw_processed_bytes += cpg->p.crypt_len; |
274 | do { | 273 | if (cpg->p.copy_back) { |
275 | int dst_copy; | 274 | int need_copy_len = cpg->p.crypt_len; |
275 | int sram_offset = 0; | ||
276 | do { | ||
277 | int dst_copy; | ||
278 | |||
279 | if (!cpg->p.sg_dst_left) { | ||
280 | ret = sg_miter_next(&cpg->p.dst_sg_it); | ||
281 | BUG_ON(!ret); | ||
282 | cpg->p.sg_dst_left = cpg->p.dst_sg_it.length; | ||
283 | cpg->p.dst_start = 0; | ||
284 | } | ||
276 | 285 | ||
277 | if (!cpg->p.sg_dst_left) { | 286 | buf = cpg->p.dst_sg_it.addr; |
278 | ret = sg_miter_next(&cpg->p.dst_sg_it); | 287 | buf += cpg->p.dst_start; |
279 | BUG_ON(!ret); | ||
280 | cpg->p.sg_dst_left = cpg->p.dst_sg_it.length; | ||
281 | cpg->p.dst_start = 0; | ||
282 | } | ||
283 | 288 | ||
284 | buf = cpg->p.dst_sg_it.addr; | 289 | dst_copy = min(need_copy_len, cpg->p.sg_dst_left); |
285 | buf += cpg->p.dst_start; | ||
286 | 290 | ||
287 | dst_copy = min(need_copy_len, cpg->p.sg_dst_left); | 291 | memcpy(buf, |
292 | cpg->sram + SRAM_DATA_OUT_START + sram_offset, | ||
293 | dst_copy); | ||
294 | sram_offset += dst_copy; | ||
295 | cpg->p.sg_dst_left -= dst_copy; | ||
296 | need_copy_len -= dst_copy; | ||
297 | cpg->p.dst_start += dst_copy; | ||
298 | } while (need_copy_len > 0); | ||
299 | } | ||
288 | 300 | ||
289 | memcpy(buf, | ||
290 | cpg->sram + SRAM_DATA_OUT_START + sram_offset, | ||
291 | dst_copy); | ||
292 | sram_offset += dst_copy; | ||
293 | cpg->p.sg_dst_left -= dst_copy; | ||
294 | need_copy_len -= dst_copy; | ||
295 | cpg->p.dst_start += dst_copy; | ||
296 | } while (need_copy_len > 0); | ||
297 | 301 | ||
298 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | 302 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); |
299 | if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { | 303 | if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { |
@@ -336,6 +340,7 @@ static void mv_enqueue_new_req(struct ablkcipher_request *req) | |||
336 | p->hw_nbytes = req->nbytes; | 340 | p->hw_nbytes = req->nbytes; |
337 | p->complete = mv_crypto_algo_completion; | 341 | p->complete = mv_crypto_algo_completion; |
338 | p->process = mv_process_current_q; | 342 | p->process = mv_process_current_q; |
343 | p->copy_back = 1; | ||
339 | 344 | ||
340 | num_sgs = count_sgs(req->src, req->nbytes); | 345 | num_sgs = count_sgs(req->src, req->nbytes); |
341 | sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); | 346 | sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); |