]>
Commit | Line | Data |
---|---|---|
903d87f4 AF |
1 | From 0328ac267564089d9cedfb568f936d30a6debd21 Mon Sep 17 00:00:00 2001 |
2 | From: Uri Simchoni <uri@jdland.co.il> | |
3 | Date: Thu, 8 Apr 2010 19:25:37 +0300 | |
4 | Subject: [PATCH] crypto: mv_cesa - Invoke the user callback from a softirq | |
5 | context | |
6 | ||
7 | Invoke the user callback from a softirq context | |
8 | ||
9 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
10 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
11 | --- | |
12 | drivers/crypto/mv_cesa.c | 2 ++ | |
13 | 1 files changed, 2 insertions(+), 0 deletions(-) | |
14 | ||
15 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
16 | index b21ef63..3e60ba9 100644 | |
17 | --- a/drivers/crypto/mv_cesa.c | |
18 | +++ b/drivers/crypto/mv_cesa.c | |
19 | @@ -275,7 +275,9 @@ static void dequeue_complete_req(void) | |
20 | sg_miter_stop(&cpg->p.dst_sg_it); | |
21 | mv_crypto_algo_completion(); | |
22 | cpg->eng_st = ENGINE_IDLE; | |
23 | + local_bh_disable(); | |
24 | req->base.complete(&req->base, 0); | |
25 | + local_bh_enable(); | |
26 | } | |
27 | } | |
28 | ||
29 | -- | |
30 | 1.7.6.5 | |
31 | From 6bc6fcd609080461682c5cc0a1e3bf4345d6419d Mon Sep 17 00:00:00 2001 | |
32 | From: Uri Simchoni <uri@jdland.co.il> | |
33 | Date: Thu, 8 Apr 2010 19:25:56 +0300 | |
34 | Subject: [PATCH] crypto: mv_cesa - Remove compiler warning in mv_cesa driver | |
35 | ||
36 | Remove compiler warning | |
37 | ||
38 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
39 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
40 | --- | |
41 | drivers/crypto/mv_cesa.c | 1 + | |
42 | 1 files changed, 1 insertions(+), 0 deletions(-) | |
43 | ||
44 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
45 | index 3e60ba9..37d9f06 100644 | |
46 | --- a/drivers/crypto/mv_cesa.c | |
47 | +++ b/drivers/crypto/mv_cesa.c | |
48 | @@ -178,6 +178,7 @@ static void mv_process_current_q(int first_block) | |
49 | op.config = CFG_OP_CRYPT_ONLY | CFG_ENCM_AES | CFG_ENC_MODE_ECB; | |
50 | break; | |
51 | case COP_AES_CBC: | |
52 | + default: | |
53 | op.config = CFG_OP_CRYPT_ONLY | CFG_ENCM_AES | CFG_ENC_MODE_CBC; | |
54 | op.enc_iv = ENC_IV_POINT(SRAM_DATA_IV) | | |
55 | ENC_IV_BUF_POINT(SRAM_DATA_IV_BUF); | |
56 | -- | |
57 | 1.7.6.5 | |
58 | X-Git-Url: http://git.kernelconcepts.de/?p=mv-sheeva.git;a=blobdiff_plain;f=drivers%2Fcrypto%2Fmv_cesa.c;h=018a95ce0c9b0d6e6a13bff1522630799bc445b3;hp=37d9f0688e7575a3e366f6bb9eda5adc5db807b5;hb=f565e67ec1b8f4a95d21550f9b879fe86b4132e0;hpb=6bc6fcd609080461682c5cc0a1e3bf4345d6419d | |
59 | ||
60 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
61 | index 37d9f06..018a95c 100644 | |
62 | --- a/drivers/crypto/mv_cesa.c | |
63 | +++ b/drivers/crypto/mv_cesa.c | |
64 | @@ -242,6 +242,8 @@ static void dequeue_complete_req(void) | |
65 | struct ablkcipher_request *req = cpg->cur_req; | |
66 | void *buf; | |
67 | int ret; | |
68 | + int need_copy_len = cpg->p.crypt_len; | |
69 | + int sram_offset = 0; | |
70 | ||
71 | cpg->p.total_req_bytes += cpg->p.crypt_len; | |
72 | do { | |
73 | @@ -257,14 +259,16 @@ static void dequeue_complete_req(void) | |
74 | buf = cpg->p.dst_sg_it.addr; | |
75 | buf += cpg->p.dst_start; | |
76 | ||
77 | - dst_copy = min(cpg->p.crypt_len, cpg->p.sg_dst_left); | |
78 | - | |
79 | - memcpy(buf, cpg->sram + SRAM_DATA_OUT_START, dst_copy); | |
80 | + dst_copy = min(need_copy_len, cpg->p.sg_dst_left); | |
81 | ||
82 | + memcpy(buf, | |
83 | + cpg->sram + SRAM_DATA_OUT_START + sram_offset, | |
84 | + dst_copy); | |
85 | + sram_offset += dst_copy; | |
86 | cpg->p.sg_dst_left -= dst_copy; | |
87 | - cpg->p.crypt_len -= dst_copy; | |
88 | + need_copy_len -= dst_copy; | |
89 | cpg->p.dst_start += dst_copy; | |
90 | - } while (cpg->p.crypt_len > 0); | |
91 | + } while (need_copy_len > 0); | |
92 | ||
93 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | |
94 | if (cpg->p.total_req_bytes < req->nbytes) { | |
95 | From 15d4dd3594221f11a7730fcf2d5f9942b96cdd7e Mon Sep 17 00:00:00 2001 | |
96 | From: Uri Simchoni <uri@jdland.co.il> | |
97 | Date: Thu, 8 Apr 2010 19:27:02 +0300 | |
98 | Subject: [PATCH] crypto: mv_cesa - Fix situations where the src sglist spans | |
99 | more data than the request asks for | |
100 | ||
101 | Fix for situations where the source scatterlist spans more data than the | |
102 | request nbytes | |
103 | ||
104 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
105 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
106 | --- | |
107 | drivers/crypto/mv_cesa.c | 66 ++++++++++++++++++++++++++++++--------------- | |
108 | 1 files changed, 44 insertions(+), 22 deletions(-) | |
109 | ||
110 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
111 | index 018a95c..096f9ff 100644 | |
112 | --- a/drivers/crypto/mv_cesa.c | |
113 | +++ b/drivers/crypto/mv_cesa.c | |
114 | @@ -143,27 +143,45 @@ static int mv_setkey_aes(struct crypto_ablkcipher *cipher, const u8 *key, | |
115 | return 0; | |
116 | } | |
117 | ||
118 | -static void setup_data_in(struct ablkcipher_request *req) | |
119 | +static void copy_src_to_buf(struct req_progress *p, char *dbuf, int len) | |
120 | { | |
121 | int ret; | |
122 | - void *buf; | |
123 | - | |
124 | - if (!cpg->p.sg_src_left) { | |
125 | - ret = sg_miter_next(&cpg->p.src_sg_it); | |
126 | - BUG_ON(!ret); | |
127 | - cpg->p.sg_src_left = cpg->p.src_sg_it.length; | |
128 | - cpg->p.src_start = 0; | |
129 | - } | |
130 | + void *sbuf; | |
131 | + int copied = 0; | |
132 | ||
133 | - cpg->p.crypt_len = min(cpg->p.sg_src_left, cpg->max_req_size); | |
134 | - | |
135 | - buf = cpg->p.src_sg_it.addr; | |
136 | - buf += cpg->p.src_start; | |
137 | + while (1) { | |
138 | + if (!p->sg_src_left) { | |
139 | + ret = sg_miter_next(&p->src_sg_it); | |
140 | + BUG_ON(!ret); | |
141 | + p->sg_src_left = p->src_sg_it.length; | |
142 | + p->src_start = 0; | |
143 | + } | |
144 | ||
145 | - memcpy(cpg->sram + SRAM_DATA_IN_START, buf, cpg->p.crypt_len); | |
146 | + sbuf = p->src_sg_it.addr + p->src_start; | |
147 | + | |
148 | + if (p->sg_src_left <= len - copied) { | |
149 | + memcpy(dbuf + copied, sbuf, p->sg_src_left); | |
150 | + copied += p->sg_src_left; | |
151 | + p->sg_src_left = 0; | |
152 | + if (copied >= len) | |
153 | + break; | |
154 | + } else { | |
155 | + int copy_len = len - copied; | |
156 | + memcpy(dbuf + copied, sbuf, copy_len); | |
157 | + p->src_start += copy_len; | |
158 | + p->sg_src_left -= copy_len; | |
159 | + break; | |
160 | + } | |
161 | + } | |
162 | +} | |
163 | ||
164 | - cpg->p.sg_src_left -= cpg->p.crypt_len; | |
165 | - cpg->p.src_start += cpg->p.crypt_len; | |
166 | +static void setup_data_in(struct ablkcipher_request *req) | |
167 | +{ | |
168 | + struct req_progress *p = &cpg->p; | |
169 | + p->crypt_len = | |
170 | + min((int)req->nbytes - p->total_req_bytes, cpg->max_req_size); | |
171 | + copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START, | |
172 | + p->crypt_len); | |
173 | } | |
174 | ||
175 | static void mv_process_current_q(int first_block) | |
176 | @@ -289,12 +307,16 @@ static void dequeue_complete_req(void) | |
177 | static int count_sgs(struct scatterlist *sl, unsigned int total_bytes) | |
178 | { | |
179 | int i = 0; | |
180 | - | |
181 | - do { | |
182 | - total_bytes -= sl[i].length; | |
183 | - i++; | |
184 | - | |
185 | - } while (total_bytes > 0); | |
186 | + size_t cur_len; | |
187 | + | |
188 | + while (1) { | |
189 | + cur_len = sl[i].length; | |
190 | + ++i; | |
191 | + if (total_bytes > cur_len) | |
192 | + total_bytes -= cur_len; | |
193 | + else | |
194 | + break; | |
195 | + } | |
196 | ||
197 | return i; | |
198 | } | |
199 | -- | |
200 | 1.7.6.5 | |
201 | From 3b61a90502481045f56c1c41a2af35ee48ca8b80 Mon Sep 17 00:00:00 2001 | |
202 | From: Uri Simchoni <uri@jdland.co.il> | |
203 | Date: Thu, 8 Apr 2010 19:27:33 +0300 | |
204 | Subject: [PATCH] crypto: mv_cesa - Enqueue generic async requests | |
205 | ||
206 | Enqueue generic async requests rather than ablkcipher requests | |
207 | in the driver's queue | |
208 | ||
209 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
210 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
211 | --- | |
212 | drivers/crypto/mv_cesa.c | 43 ++++++++++++++++++++++++------------------- | |
213 | 1 files changed, 24 insertions(+), 19 deletions(-) | |
214 | ||
215 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
216 | index 096f9ff..8891e2e 100644 | |
217 | --- a/drivers/crypto/mv_cesa.c | |
218 | +++ b/drivers/crypto/mv_cesa.c | |
219 | @@ -39,6 +39,7 @@ enum engine_status { | |
220 | * @sg_src_left: bytes left in src to process (scatter list) | |
221 | * @src_start: offset to add to src start position (scatter list) | |
222 | * @crypt_len: length of current crypt process | |
223 | + * @hw_nbytes: total bytes to process in hw for this request | |
224 | * @sg_dst_left: bytes left dst to process in this scatter list | |
225 | * @dst_start: offset to add to dst start position (scatter list) | |
226 | * @total_req_bytes: total number of bytes processed (request). | |
227 | @@ -55,6 +56,7 @@ struct req_progress { | |
228 | int sg_src_left; | |
229 | int src_start; | |
230 | int crypt_len; | |
231 | + int hw_nbytes; | |
232 | /* dst mostly */ | |
233 | int sg_dst_left; | |
234 | int dst_start; | |
235 | @@ -71,7 +73,7 @@ struct crypto_priv { | |
236 | spinlock_t lock; | |
237 | struct crypto_queue queue; | |
238 | enum engine_status eng_st; | |
239 | - struct ablkcipher_request *cur_req; | |
240 | + struct crypto_async_request *cur_req; | |
241 | struct req_progress p; | |
242 | int max_req_size; | |
243 | int sram_size; | |
244 | @@ -175,18 +177,18 @@ static void copy_src_to_buf(struct req_progress *p, char *dbuf, int len) | |
245 | } | |
246 | } | |
247 | ||
248 | -static void setup_data_in(struct ablkcipher_request *req) | |
249 | +static void setup_data_in(void) | |
250 | { | |
251 | struct req_progress *p = &cpg->p; | |
252 | p->crypt_len = | |
253 | - min((int)req->nbytes - p->total_req_bytes, cpg->max_req_size); | |
254 | + min(p->hw_nbytes - p->total_req_bytes, cpg->max_req_size); | |
255 | copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START, | |
256 | p->crypt_len); | |
257 | } | |
258 | ||
259 | static void mv_process_current_q(int first_block) | |
260 | { | |
261 | - struct ablkcipher_request *req = cpg->cur_req; | |
262 | + struct ablkcipher_request *req = ablkcipher_request_cast(cpg->cur_req); | |
263 | struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm); | |
264 | struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req); | |
265 | struct sec_accel_config op; | |
266 | @@ -229,7 +231,7 @@ static void mv_process_current_q(int first_block) | |
267 | ENC_P_DST(SRAM_DATA_OUT_START); | |
268 | op.enc_key_p = SRAM_DATA_KEY_P; | |
269 | ||
270 | - setup_data_in(req); | |
271 | + setup_data_in(); | |
272 | op.enc_len = cpg->p.crypt_len; | |
273 | memcpy(cpg->sram + SRAM_CONFIG, &op, | |
274 | sizeof(struct sec_accel_config)); | |
275 | @@ -246,7 +248,7 @@ static void mv_process_current_q(int first_block) | |
276 | ||
277 | static void mv_crypto_algo_completion(void) | |
278 | { | |
279 | - struct ablkcipher_request *req = cpg->cur_req; | |
280 | + struct ablkcipher_request *req = ablkcipher_request_cast(cpg->cur_req); | |
281 | struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req); | |
282 | ||
283 | if (req_ctx->op != COP_AES_CBC) | |
284 | @@ -257,7 +259,7 @@ static void mv_crypto_algo_completion(void) | |
285 | ||
286 | static void dequeue_complete_req(void) | |
287 | { | |
288 | - struct ablkcipher_request *req = cpg->cur_req; | |
289 | + struct crypto_async_request *req = cpg->cur_req; | |
290 | void *buf; | |
291 | int ret; | |
292 | int need_copy_len = cpg->p.crypt_len; | |
293 | @@ -289,7 +291,7 @@ static void dequeue_complete_req(void) | |
294 | } while (need_copy_len > 0); | |
295 | ||
296 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | |
297 | - if (cpg->p.total_req_bytes < req->nbytes) { | |
298 | + if (cpg->p.total_req_bytes < cpg->p.hw_nbytes) { | |
299 | /* process next scatter list entry */ | |
300 | cpg->eng_st = ENGINE_BUSY; | |
301 | mv_process_current_q(0); | |
302 | @@ -299,7 +301,7 @@ static void dequeue_complete_req(void) | |
303 | mv_crypto_algo_completion(); | |
304 | cpg->eng_st = ENGINE_IDLE; | |
305 | local_bh_disable(); | |
306 | - req->base.complete(&req->base, 0); | |
307 | + req->complete(req, 0); | |
308 | local_bh_enable(); | |
309 | } | |
310 | } | |
311 | @@ -323,16 +325,19 @@ static int count_sgs(struct scatterlist *sl, unsigned int total_bytes) | |
312 | ||
313 | static void mv_enqueue_new_req(struct ablkcipher_request *req) | |
314 | { | |
315 | + struct req_progress *p = &cpg->p; | |
316 | int num_sgs; | |
317 | ||
318 | - cpg->cur_req = req; | |
319 | - memset(&cpg->p, 0, sizeof(struct req_progress)); | |
320 | + cpg->cur_req = &req->base; | |
321 | + memset(p, 0, sizeof(struct req_progress)); | |
322 | + p->hw_nbytes = req->nbytes; | |
323 | ||
324 | num_sgs = count_sgs(req->src, req->nbytes); | |
325 | - sg_miter_start(&cpg->p.src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); | |
326 | + sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); | |
327 | ||
328 | num_sgs = count_sgs(req->dst, req->nbytes); | |
329 | - sg_miter_start(&cpg->p.dst_sg_it, req->dst, num_sgs, SG_MITER_TO_SG); | |
330 | + sg_miter_start(&p->dst_sg_it, req->dst, num_sgs, SG_MITER_TO_SG); | |
331 | + | |
332 | mv_process_current_q(1); | |
333 | } | |
334 | ||
335 | @@ -378,13 +383,13 @@ static int queue_manag(void *data) | |
336 | return 0; | |
337 | } | |
338 | ||
339 | -static int mv_handle_req(struct ablkcipher_request *req) | |
340 | +static int mv_handle_req(struct crypto_async_request *req) | |
341 | { | |
342 | unsigned long flags; | |
343 | int ret; | |
344 | ||
345 | spin_lock_irqsave(&cpg->lock, flags); | |
346 | - ret = ablkcipher_enqueue_request(&cpg->queue, req); | |
347 | + ret = crypto_enqueue_request(&cpg->queue, req); | |
348 | spin_unlock_irqrestore(&cpg->lock, flags); | |
349 | wake_up_process(cpg->queue_th); | |
350 | return ret; | |
351 | @@ -397,7 +402,7 @@ static int mv_enc_aes_ecb(struct ablkcipher_request *req) | |
352 | req_ctx->op = COP_AES_ECB; | |
353 | req_ctx->decrypt = 0; | |
354 | ||
355 | - return mv_handle_req(req); | |
356 | + return mv_handle_req(&req->base); | |
357 | } | |
358 | ||
359 | static int mv_dec_aes_ecb(struct ablkcipher_request *req) | |
360 | @@ -409,7 +414,7 @@ static int mv_dec_aes_ecb(struct ablkcipher_request *req) | |
361 | req_ctx->decrypt = 1; | |
362 | ||
363 | compute_aes_dec_key(ctx); | |
364 | - return mv_handle_req(req); | |
365 | + return mv_handle_req(&req->base); | |
366 | } | |
367 | ||
368 | static int mv_enc_aes_cbc(struct ablkcipher_request *req) | |
369 | @@ -419,7 +424,7 @@ static int mv_enc_aes_cbc(struct ablkcipher_request *req) | |
370 | req_ctx->op = COP_AES_CBC; | |
371 | req_ctx->decrypt = 0; | |
372 | ||
373 | - return mv_handle_req(req); | |
374 | + return mv_handle_req(&req->base); | |
375 | } | |
376 | ||
377 | static int mv_dec_aes_cbc(struct ablkcipher_request *req) | |
378 | @@ -431,7 +436,7 @@ static int mv_dec_aes_cbc(struct ablkcipher_request *req) | |
379 | req_ctx->decrypt = 1; | |
380 | ||
381 | compute_aes_dec_key(ctx); | |
382 | - return mv_handle_req(req); | |
383 | + return mv_handle_req(&req->base); | |
384 | } | |
385 | ||
386 | static int mv_cra_init(struct crypto_tfm *tfm) | |
387 | -- | |
388 | 1.7.6.5 | |
389 | From 7a5f691ef03f4c01d2703b5ec4ddd4c17e645dec Mon Sep 17 00:00:00 2001 | |
390 | From: Uri Simchoni <uri@jdland.co.il> | |
391 | Date: Thu, 8 Apr 2010 19:29:16 +0300 | |
392 | Subject: [PATCH] crypto: mv_cesa - Rename a variable to a more suitable name | |
393 | ||
394 | Rename a variable to a more suitable name | |
395 | ||
396 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
397 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
398 | --- | |
399 | drivers/crypto/mv_cesa.c | 10 +++++----- | |
400 | 1 files changed, 5 insertions(+), 5 deletions(-) | |
401 | ||
402 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
403 | index 8891e2e..4262932 100644 | |
404 | --- a/drivers/crypto/mv_cesa.c | |
405 | +++ b/drivers/crypto/mv_cesa.c | |
406 | @@ -42,7 +42,7 @@ enum engine_status { | |
407 | * @hw_nbytes: total bytes to process in hw for this request | |
408 | * @sg_dst_left: bytes left dst to process in this scatter list | |
409 | * @dst_start: offset to add to dst start position (scatter list) | |
410 | - * @total_req_bytes: total number of bytes processed (request). | |
411 | + * @hw_processed_bytes: number of bytes processed by hw (request). | |
412 | * | |
413 | * sg helper are used to iterate over the scatterlist. Since the size of the | |
414 | * SRAM may be less than the scatter size, this struct struct is used to keep | |
415 | @@ -60,7 +60,7 @@ struct req_progress { | |
416 | /* dst mostly */ | |
417 | int sg_dst_left; | |
418 | int dst_start; | |
419 | - int total_req_bytes; | |
420 | + int hw_processed_bytes; | |
421 | }; | |
422 | ||
423 | struct crypto_priv { | |
424 | @@ -181,7 +181,7 @@ static void setup_data_in(void) | |
425 | { | |
426 | struct req_progress *p = &cpg->p; | |
427 | p->crypt_len = | |
428 | - min(p->hw_nbytes - p->total_req_bytes, cpg->max_req_size); | |
429 | + min(p->hw_nbytes - p->hw_processed_bytes, cpg->max_req_size); | |
430 | copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START, | |
431 | p->crypt_len); | |
432 | } | |
433 | @@ -265,7 +265,7 @@ static void dequeue_complete_req(void) | |
434 | int need_copy_len = cpg->p.crypt_len; | |
435 | int sram_offset = 0; | |
436 | ||
437 | - cpg->p.total_req_bytes += cpg->p.crypt_len; | |
438 | + cpg->p.hw_processed_bytes += cpg->p.crypt_len; | |
439 | do { | |
440 | int dst_copy; | |
441 | ||
442 | @@ -291,7 +291,7 @@ static void dequeue_complete_req(void) | |
443 | } while (need_copy_len > 0); | |
444 | ||
445 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | |
446 | - if (cpg->p.total_req_bytes < cpg->p.hw_nbytes) { | |
447 | + if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { | |
448 | /* process next scatter list entry */ | |
449 | cpg->eng_st = ENGINE_BUSY; | |
450 | mv_process_current_q(0); | |
451 | -- | |
452 | 1.6.5.GIT | |
453 | From a58094ac5f95d6969e5c52ff096d2fd2864542af Mon Sep 17 00:00:00 2001 | |
454 | From: Uri Simchoni <uri@jdland.co.il> | |
455 | Date: Thu, 8 Apr 2010 19:30:19 +0300 | |
456 | Subject: [PATCH] crypto: mv_cesa - Execute some code via function pointers | |
457 | rathr than direct calls | |
458 | ||
459 | Execute some code via function pointers rathr than direct calls | |
460 | (to allow customization in the hashing request) | |
461 | ||
462 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
463 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
464 | --- | |
465 | drivers/crypto/mv_cesa.c | 13 +++++++++---- | |
466 | 1 files changed, 9 insertions(+), 4 deletions(-) | |
467 | ||
468 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
469 | index 4262932..2b4f07a 100644 | |
470 | --- a/drivers/crypto/mv_cesa.c | |
471 | +++ b/drivers/crypto/mv_cesa.c | |
472 | @@ -51,6 +51,8 @@ enum engine_status { | |
473 | struct req_progress { | |
474 | struct sg_mapping_iter src_sg_it; | |
475 | struct sg_mapping_iter dst_sg_it; | |
476 | + void (*complete) (void); | |
477 | + void (*process) (int is_first); | |
478 | ||
479 | /* src mostly */ | |
480 | int sg_src_left; | |
481 | @@ -251,6 +253,9 @@ static void mv_crypto_algo_completion(void) | |
482 | struct ablkcipher_request *req = ablkcipher_request_cast(cpg->cur_req); | |
483 | struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req); | |
484 | ||
485 | + sg_miter_stop(&cpg->p.src_sg_it); | |
486 | + sg_miter_stop(&cpg->p.dst_sg_it); | |
487 | + | |
488 | if (req_ctx->op != COP_AES_CBC) | |
489 | return ; | |
490 | ||
491 | @@ -294,11 +299,9 @@ static void dequeue_complete_req(void) | |
492 | if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { | |
493 | /* process next scatter list entry */ | |
494 | cpg->eng_st = ENGINE_BUSY; | |
495 | - mv_process_current_q(0); | |
496 | + cpg->p.process(0); | |
497 | } else { | |
498 | - sg_miter_stop(&cpg->p.src_sg_it); | |
499 | - sg_miter_stop(&cpg->p.dst_sg_it); | |
500 | - mv_crypto_algo_completion(); | |
501 | + cpg->p.complete(); | |
502 | cpg->eng_st = ENGINE_IDLE; | |
503 | local_bh_disable(); | |
504 | req->complete(req, 0); | |
505 | @@ -331,6 +334,8 @@ static void mv_enqueue_new_req(struct ablkcipher_request *req) | |
506 | cpg->cur_req = &req->base; | |
507 | memset(p, 0, sizeof(struct req_progress)); | |
508 | p->hw_nbytes = req->nbytes; | |
509 | + p->complete = mv_crypto_algo_completion; | |
510 | + p->process = mv_process_current_q; | |
511 | ||
512 | num_sgs = count_sgs(req->src, req->nbytes); | |
513 | sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); | |
514 | -- | |
515 | 1.7.6.5 | |
516 | X-Git-Url: http://git.kernelconcepts.de/?p=mv-sheeva.git;a=blobdiff_plain;f=drivers%2Fcrypto%2Fmv_cesa.c;h=49a22060fb51a46afff004ddade3dacf378aecd8;hp=2b4f07aa89e8ba7422de65eea027e06daa5f7797;hb=f0d03deaad05d9cc99cd2ee0475c9ecd726c19ae;hpb=a58094ac5f95d6969e5c52ff096d2fd2864542af | |
517 | ||
518 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
519 | index 2b4f07a..49a2206 100644 | |
520 | --- a/drivers/crypto/mv_cesa.c | |
521 | +++ b/drivers/crypto/mv_cesa.c | |
522 | @@ -40,6 +40,7 @@ enum engine_status { | |
523 | * @src_start: offset to add to src start position (scatter list) | |
524 | * @crypt_len: length of current crypt process | |
525 | * @hw_nbytes: total bytes to process in hw for this request | |
526 | + * @copy_back: whether to copy data back (crypt) or not (hash) | |
527 | * @sg_dst_left: bytes left dst to process in this scatter list | |
528 | * @dst_start: offset to add to dst start position (scatter list) | |
529 | * @hw_processed_bytes: number of bytes processed by hw (request). | |
530 | @@ -60,6 +61,7 @@ struct req_progress { | |
531 | int crypt_len; | |
532 | int hw_nbytes; | |
533 | /* dst mostly */ | |
534 | + int copy_back; | |
535 | int sg_dst_left; | |
536 | int dst_start; | |
537 | int hw_processed_bytes; | |
538 | @@ -267,33 +269,35 @@ static void dequeue_complete_req(void) | |
539 | struct crypto_async_request *req = cpg->cur_req; | |
540 | void *buf; | |
541 | int ret; | |
542 | - int need_copy_len = cpg->p.crypt_len; | |
543 | - int sram_offset = 0; | |
544 | - | |
545 | cpg->p.hw_processed_bytes += cpg->p.crypt_len; | |
546 | - do { | |
547 | - int dst_copy; | |
548 | + if (cpg->p.copy_back) { | |
549 | + int need_copy_len = cpg->p.crypt_len; | |
550 | + int sram_offset = 0; | |
551 | + do { | |
552 | + int dst_copy; | |
553 | + | |
554 | + if (!cpg->p.sg_dst_left) { | |
555 | + ret = sg_miter_next(&cpg->p.dst_sg_it); | |
556 | + BUG_ON(!ret); | |
557 | + cpg->p.sg_dst_left = cpg->p.dst_sg_it.length; | |
558 | + cpg->p.dst_start = 0; | |
559 | + } | |
560 | ||
561 | - if (!cpg->p.sg_dst_left) { | |
562 | - ret = sg_miter_next(&cpg->p.dst_sg_it); | |
563 | - BUG_ON(!ret); | |
564 | - cpg->p.sg_dst_left = cpg->p.dst_sg_it.length; | |
565 | - cpg->p.dst_start = 0; | |
566 | - } | |
567 | + buf = cpg->p.dst_sg_it.addr; | |
568 | + buf += cpg->p.dst_start; | |
569 | ||
570 | - buf = cpg->p.dst_sg_it.addr; | |
571 | - buf += cpg->p.dst_start; | |
572 | + dst_copy = min(need_copy_len, cpg->p.sg_dst_left); | |
573 | ||
574 | - dst_copy = min(need_copy_len, cpg->p.sg_dst_left); | |
575 | + memcpy(buf, | |
576 | + cpg->sram + SRAM_DATA_OUT_START + sram_offset, | |
577 | + dst_copy); | |
578 | + sram_offset += dst_copy; | |
579 | + cpg->p.sg_dst_left -= dst_copy; | |
580 | + need_copy_len -= dst_copy; | |
581 | + cpg->p.dst_start += dst_copy; | |
582 | + } while (need_copy_len > 0); | |
583 | + } | |
584 | ||
585 | - memcpy(buf, | |
586 | - cpg->sram + SRAM_DATA_OUT_START + sram_offset, | |
587 | - dst_copy); | |
588 | - sram_offset += dst_copy; | |
589 | - cpg->p.sg_dst_left -= dst_copy; | |
590 | - need_copy_len -= dst_copy; | |
591 | - cpg->p.dst_start += dst_copy; | |
592 | - } while (need_copy_len > 0); | |
593 | ||
594 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | |
595 | if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { | |
596 | @@ -336,6 +340,7 @@ static void mv_enqueue_new_req(struct ablkcipher_request *req) | |
597 | p->hw_nbytes = req->nbytes; | |
598 | p->complete = mv_crypto_algo_completion; | |
599 | p->process = mv_process_current_q; | |
600 | + p->copy_back = 1; | |
601 | ||
602 | num_sgs = count_sgs(req->src, req->nbytes); | |
603 | sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG); | |
604 | From 0c5c6c4bae8fe9ae3d86b44c332eb1267df1ec99 Mon Sep 17 00:00:00 2001 | |
605 | From: Uri Simchoni <uri@jdland.co.il> | |
606 | Date: Thu, 8 Apr 2010 19:33:26 +0300 | |
607 | Subject: [PATCH] crypto: mv_cesa - Support processing of data from previous | |
608 | requests | |
609 | ||
610 | Support processing of data from previous requests (as in hashing | |
611 | update/final requests). | |
612 | ||
613 | Signed-off-by: Uri Simchoni <uri@jdland.co.il> | |
614 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | |
615 | --- | |
616 | drivers/crypto/mv_cesa.c | 8 +++++--- | |
617 | 1 files changed, 5 insertions(+), 3 deletions(-) | |
618 | ||
619 | diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c | |
620 | index 49a2206..d0fb10e 100644 | |
621 | --- a/drivers/crypto/mv_cesa.c | |
622 | +++ b/drivers/crypto/mv_cesa.c | |
623 | @@ -184,10 +184,11 @@ static void copy_src_to_buf(struct req_progress *p, char *dbuf, int len) | |
624 | static void setup_data_in(void) | |
625 | { | |
626 | struct req_progress *p = &cpg->p; | |
627 | - p->crypt_len = | |
628 | + int data_in_sram = | |
629 | min(p->hw_nbytes - p->hw_processed_bytes, cpg->max_req_size); | |
630 | - copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START, | |
631 | - p->crypt_len); | |
632 | + copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START + p->crypt_len, | |
633 | + data_in_sram - p->crypt_len); | |
634 | + p->crypt_len = data_in_sram; | |
635 | } | |
636 | ||
637 | static void mv_process_current_q(int first_block) | |
638 | @@ -298,6 +299,7 @@ static void dequeue_complete_req(void) | |
639 | } while (need_copy_len > 0); | |
640 | } | |
641 | ||
642 | + cpg->p.crypt_len = 0; | |
643 | ||
644 | BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE); | |
645 | if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) { | |
646 | -- | |
647 | 1.7.6.5 |