summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorGilad Ben-Yossef <gilad@benyossef.com>2017-12-17 03:29:02 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2017-12-28 01:56:40 -0500
commit8fcdc86856b24d3f76b4d70665f2cbbe5102d8de (patch)
tree13bc658a5d54c3921d47c08adcb6f5ec45733d2f /crypto
parent4431bd49530c7379dffaf0963d69bdab7fbead05 (diff)
crypto: tcrypt - allow setting num of bufs
For multiple buffers speed tests, the number of buffers, or requests, used actually sets the level of parallelism a tfm provider may utilize to hide latency. The existing number (of 8) is good for some software based providers but not enough for many HW providers with deep FIFOs. Add a module parameter that allows setting the number of multiple buffers/requests used, leaving the default at 8. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tcrypt.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 69c8e6392ffc..260436004a76 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -67,6 +67,7 @@ static char *alg = NULL;
67static u32 type; 67static u32 type;
68static u32 mask; 68static u32 mask;
69static int mode; 69static int mode;
70static u32 num_mb = 8;
70static char *tvmem[TVMEMSIZE]; 71static char *tvmem[TVMEMSIZE];
71 72
72static char *check[] = { 73static char *check[] = {
@@ -413,7 +414,7 @@ struct test_mb_ahash_data {
413}; 414};
414 415
415static void test_mb_ahash_speed(const char *algo, unsigned int sec, 416static void test_mb_ahash_speed(const char *algo, unsigned int sec,
416 struct hash_speed *speed) 417 struct hash_speed *speed, u32 num_mb)
417{ 418{
418 struct test_mb_ahash_data *data; 419 struct test_mb_ahash_data *data;
419 struct crypto_ahash *tfm; 420 struct crypto_ahash *tfm;
@@ -422,7 +423,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
422 unsigned int i, j, k; 423 unsigned int i, j, k;
423 int ret; 424 int ret;
424 425
425 data = kzalloc(sizeof(*data) * 8, GFP_KERNEL); 426 data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
426 if (!data) 427 if (!data)
427 return; 428 return;
428 429
@@ -433,7 +434,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
433 goto free_data; 434 goto free_data;
434 } 435 }
435 436
436 for (i = 0; i < 8; ++i) { 437 for (i = 0; i < num_mb; ++i) {
437 if (testmgr_alloc_buf(data[i].xbuf)) 438 if (testmgr_alloc_buf(data[i].xbuf))
438 goto out; 439 goto out;
439 440
@@ -473,7 +474,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
473 if (speed[i].klen) 474 if (speed[i].klen)
474 crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); 475 crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
475 476
476 for (k = 0; k < 8; k++) 477 for (k = 0; k < num_mb; k++)
477 ahash_request_set_crypt(data[k].req, data[k].sg, 478 ahash_request_set_crypt(data[k].req, data[k].sg,
478 data[k].result, speed[i].blen); 479 data[k].result, speed[i].blen);
479 480
@@ -484,7 +485,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
484 485
485 start = get_cycles(); 486 start = get_cycles();
486 487
487 for (k = 0; k < 8; k++) { 488 for (k = 0; k < num_mb; k++) {
488 ret = crypto_ahash_digest(data[k].req); 489 ret = crypto_ahash_digest(data[k].req);
489 if (ret == -EINPROGRESS) { 490 if (ret == -EINPROGRESS) {
490 ret = 0; 491 ret = 0;
@@ -509,7 +510,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
509 end = get_cycles(); 510 end = get_cycles();
510 cycles = end - start; 511 cycles = end - start;
511 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", 512 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
512 cycles, cycles / (8 * speed[i].blen)); 513 cycles, cycles / (num_mb * speed[i].blen));
513 514
514 if (ret) { 515 if (ret) {
515 pr_err("At least one hashing failed ret=%d\n", ret); 516 pr_err("At least one hashing failed ret=%d\n", ret);
@@ -518,10 +519,10 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
518 } 519 }
519 520
520out: 521out:
521 for (k = 0; k < 8; ++k) 522 for (k = 0; k < num_mb; ++k)
522 ahash_request_free(data[k].req); 523 ahash_request_free(data[k].req);
523 524
524 for (k = 0; k < 8; ++k) 525 for (k = 0; k < num_mb; ++k)
525 testmgr_free_buf(data[k].xbuf); 526 testmgr_free_buf(data[k].xbuf);
526 527
527 crypto_free_ahash(tfm); 528 crypto_free_ahash(tfm);
@@ -1815,19 +1816,23 @@ static int do_test(const char *alg, u32 type, u32 mask, int m)
1815 if (mode > 400 && mode < 500) break; 1816 if (mode > 400 && mode < 500) break;
1816 /* fall through */ 1817 /* fall through */
1817 case 422: 1818 case 422:
1818 test_mb_ahash_speed("sha1", sec, generic_hash_speed_template); 1819 test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
1820 num_mb);
1819 if (mode > 400 && mode < 500) break; 1821 if (mode > 400 && mode < 500) break;
1820 /* fall through */ 1822 /* fall through */
1821 case 423: 1823 case 423:
1822 test_mb_ahash_speed("sha256", sec, generic_hash_speed_template); 1824 test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
1825 num_mb);
1823 if (mode > 400 && mode < 500) break; 1826 if (mode > 400 && mode < 500) break;
1824 /* fall through */ 1827 /* fall through */
1825 case 424: 1828 case 424:
1826 test_mb_ahash_speed("sha512", sec, generic_hash_speed_template); 1829 test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
1830 num_mb);
1827 if (mode > 400 && mode < 500) break; 1831 if (mode > 400 && mode < 500) break;
1828 /* fall through */ 1832 /* fall through */
1829 case 425: 1833 case 425:
1830 test_mb_ahash_speed("sm3", sec, generic_hash_speed_template); 1834 test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
1835 num_mb);
1831 if (mode > 400 && mode < 500) break; 1836 if (mode > 400 && mode < 500) break;
1832 /* fall through */ 1837 /* fall through */
1833 case 499: 1838 case 499:
@@ -2106,6 +2111,8 @@ module_param(mode, int, 0);
2106module_param(sec, uint, 0); 2111module_param(sec, uint, 0);
2107MODULE_PARM_DESC(sec, "Length in seconds of speed tests " 2112MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
2108 "(defaults to zero which uses CPU cycles instead)"); 2113 "(defaults to zero which uses CPU cycles instead)");
2114module_param(num_mb, uint, 0000);
2115MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
2109 2116
2110MODULE_LICENSE("GPL"); 2117MODULE_LICENSE("GPL");
2111MODULE_DESCRIPTION("Quick & dirty crypto testing module"); 2118MODULE_DESCRIPTION("Quick & dirty crypto testing module");