aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVutla, Lokesh <lokeshvutla@ti.com>2015-07-07 11:31:49 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-07-08 03:18:47 -0400
commit1425d2d17f7309c65e2bd124e0ce8ace743b17f2 (patch)
treee9343e7cd3b1dab4fd3749d29d770bdf968b53e3
parent340d9d317eb93039754004621c6c5cb1a5e9735c (diff)
crypto: tcrypt - Fix AEAD speed tests
The AEAD speed tests doesn't do a wait_for_completition, if the return value is EINPROGRESS or EBUSY. Fixing it here. Also add a test case for gcm(aes). Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/tcrypt.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 9f6f10b498ba..3603c7c12d3c 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -73,6 +73,22 @@ static char *check[] = {
73 "lzo", "cts", "zlib", NULL 73 "lzo", "cts", "zlib", NULL
74}; 74};
75 75
76struct tcrypt_result {
77 struct completion completion;
78 int err;
79};
80
81static void tcrypt_complete(struct crypto_async_request *req, int err)
82{
83 struct tcrypt_result *res = req->data;
84
85 if (err == -EINPROGRESS)
86 return;
87
88 res->err = err;
89 complete(&res->completion);
90}
91
76static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, 92static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
77 struct scatterlist *sg, int blen, int secs) 93 struct scatterlist *sg, int blen, int secs)
78{ 94{
@@ -143,6 +159,20 @@ out:
143 return ret; 159 return ret;
144} 160}
145 161
162static inline int do_one_aead_op(struct aead_request *req, int ret)
163{
164 if (ret == -EINPROGRESS || ret == -EBUSY) {
165 struct tcrypt_result *tr = req->base.data;
166
167 ret = wait_for_completion_interruptible(&tr->completion);
168 if (!ret)
169 ret = tr->err;
170 reinit_completion(&tr->completion);
171 }
172
173 return ret;
174}
175
146static int test_aead_jiffies(struct aead_request *req, int enc, 176static int test_aead_jiffies(struct aead_request *req, int enc,
147 int blen, int secs) 177 int blen, int secs)
148{ 178{
@@ -153,9 +183,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,
153 for (start = jiffies, end = start + secs * HZ, bcount = 0; 183 for (start = jiffies, end = start + secs * HZ, bcount = 0;
154 time_before(jiffies, end); bcount++) { 184 time_before(jiffies, end); bcount++) {
155 if (enc) 185 if (enc)
156 ret = crypto_aead_encrypt(req); 186 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
157 else 187 else
158 ret = crypto_aead_decrypt(req); 188 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
159 189
160 if (ret) 190 if (ret)
161 return ret; 191 return ret;
@@ -177,9 +207,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
177 /* Warm-up run. */ 207 /* Warm-up run. */
178 for (i = 0; i < 4; i++) { 208 for (i = 0; i < 4; i++) {
179 if (enc) 209 if (enc)
180 ret = crypto_aead_encrypt(req); 210 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
181 else 211 else
182 ret = crypto_aead_decrypt(req); 212 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
183 213
184 if (ret) 214 if (ret)
185 goto out; 215 goto out;
@@ -191,9 +221,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
191 221
192 start = get_cycles(); 222 start = get_cycles();
193 if (enc) 223 if (enc)
194 ret = crypto_aead_encrypt(req); 224 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
195 else 225 else
196 ret = crypto_aead_decrypt(req); 226 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
197 end = get_cycles(); 227 end = get_cycles();
198 228
199 if (ret) 229 if (ret)
@@ -286,6 +316,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
286 char *axbuf[XBUFSIZE]; 316 char *axbuf[XBUFSIZE];
287 unsigned int *b_size; 317 unsigned int *b_size;
288 unsigned int iv_len; 318 unsigned int iv_len;
319 struct tcrypt_result result;
289 320
290 iv = kzalloc(MAX_IVLEN, GFP_KERNEL); 321 iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
291 if (!iv) 322 if (!iv)
@@ -321,6 +352,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
321 goto out_notfm; 352 goto out_notfm;
322 } 353 }
323 354
355 init_completion(&result.completion);
324 printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, 356 printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
325 get_driver_name(crypto_aead, tfm), e); 357 get_driver_name(crypto_aead, tfm), e);
326 358
@@ -331,6 +363,9 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
331 goto out_noreq; 363 goto out_noreq;
332 } 364 }
333 365
366 aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
367 tcrypt_complete, &result);
368
334 i = 0; 369 i = 0;
335 do { 370 do {
336 b_size = aead_sizes; 371 b_size = aead_sizes;
@@ -749,22 +784,6 @@ out:
749 crypto_free_hash(tfm); 784 crypto_free_hash(tfm);
750} 785}
751 786
752struct tcrypt_result {
753 struct completion completion;
754 int err;
755};
756
757static void tcrypt_complete(struct crypto_async_request *req, int err)
758{
759 struct tcrypt_result *res = req->data;
760
761 if (err == -EINPROGRESS)
762 return;
763
764 res->err = err;
765 complete(&res->completion);
766}
767
768static inline int do_one_ahash_op(struct ahash_request *req, int ret) 787static inline int do_one_ahash_op(struct ahash_request *req, int ret)
769{ 788{
770 if (ret == -EINPROGRESS || ret == -EBUSY) { 789 if (ret == -EINPROGRESS || ret == -EBUSY) {
@@ -1760,6 +1779,8 @@ static int do_test(const char *alg, u32 type, u32 mask, int m)
1760 case 211: 1779 case 211:
1761 test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, 1780 test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
1762 NULL, 0, 16, 8, aead_speed_template_20); 1781 NULL, 0, 16, 8, aead_speed_template_20);
1782 test_aead_speed("gcm(aes)", ENCRYPT, sec,
1783 NULL, 0, 16, 8, aead_speed_template_20);
1763 break; 1784 break;
1764 1785
1765 case 212: 1786 case 212: