mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 03:54:02 +00:00
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>
This commit is contained in:
parent
340d9d317e
commit
1425d2d17f
1 changed files with 43 additions and 22 deletions
|
@ -73,6 +73,22 @@ static char *check[] = {
|
||||||
"lzo", "cts", "zlib", NULL
|
"lzo", "cts", "zlib", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tcrypt_result {
|
||||||
|
struct completion completion;
|
||||||
|
int err;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void tcrypt_complete(struct crypto_async_request *req, int err)
|
||||||
|
{
|
||||||
|
struct tcrypt_result *res = req->data;
|
||||||
|
|
||||||
|
if (err == -EINPROGRESS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
res->err = err;
|
||||||
|
complete(&res->completion);
|
||||||
|
}
|
||||||
|
|
||||||
static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
|
static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
|
||||||
struct scatterlist *sg, int blen, int secs)
|
struct scatterlist *sg, int blen, int secs)
|
||||||
{
|
{
|
||||||
|
@ -143,6 +159,20 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int do_one_aead_op(struct aead_request *req, int ret)
|
||||||
|
{
|
||||||
|
if (ret == -EINPROGRESS || ret == -EBUSY) {
|
||||||
|
struct tcrypt_result *tr = req->base.data;
|
||||||
|
|
||||||
|
ret = wait_for_completion_interruptible(&tr->completion);
|
||||||
|
if (!ret)
|
||||||
|
ret = tr->err;
|
||||||
|
reinit_completion(&tr->completion);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int test_aead_jiffies(struct aead_request *req, int enc,
|
static int test_aead_jiffies(struct aead_request *req, int enc,
|
||||||
int blen, int secs)
|
int blen, int secs)
|
||||||
{
|
{
|
||||||
|
@ -153,9 +183,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,
|
||||||
for (start = jiffies, end = start + secs * HZ, bcount = 0;
|
for (start = jiffies, end = start + secs * HZ, bcount = 0;
|
||||||
time_before(jiffies, end); bcount++) {
|
time_before(jiffies, end); bcount++) {
|
||||||
if (enc)
|
if (enc)
|
||||||
ret = crypto_aead_encrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_encrypt(req));
|
||||||
else
|
else
|
||||||
ret = crypto_aead_decrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -177,9 +207,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
|
||||||
/* Warm-up run. */
|
/* Warm-up run. */
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (enc)
|
if (enc)
|
||||||
ret = crypto_aead_encrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_encrypt(req));
|
||||||
else
|
else
|
||||||
ret = crypto_aead_decrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -191,9 +221,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
|
||||||
|
|
||||||
start = get_cycles();
|
start = get_cycles();
|
||||||
if (enc)
|
if (enc)
|
||||||
ret = crypto_aead_encrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_encrypt(req));
|
||||||
else
|
else
|
||||||
ret = crypto_aead_decrypt(req);
|
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
|
||||||
end = get_cycles();
|
end = get_cycles();
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -286,6 +316,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
|
||||||
char *axbuf[XBUFSIZE];
|
char *axbuf[XBUFSIZE];
|
||||||
unsigned int *b_size;
|
unsigned int *b_size;
|
||||||
unsigned int iv_len;
|
unsigned int iv_len;
|
||||||
|
struct tcrypt_result result;
|
||||||
|
|
||||||
iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
|
iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
|
||||||
if (!iv)
|
if (!iv)
|
||||||
|
@ -321,6 +352,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
|
||||||
goto out_notfm;
|
goto out_notfm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_completion(&result.completion);
|
||||||
printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
|
printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
|
||||||
get_driver_name(crypto_aead, tfm), e);
|
get_driver_name(crypto_aead, tfm), e);
|
||||||
|
|
||||||
|
@ -331,6 +363,9 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
|
||||||
goto out_noreq;
|
goto out_noreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
|
||||||
|
tcrypt_complete, &result);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
b_size = aead_sizes;
|
b_size = aead_sizes;
|
||||||
|
@ -749,22 +784,6 @@ out:
|
||||||
crypto_free_hash(tfm);
|
crypto_free_hash(tfm);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tcrypt_result {
|
|
||||||
struct completion completion;
|
|
||||||
int err;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void tcrypt_complete(struct crypto_async_request *req, int err)
|
|
||||||
{
|
|
||||||
struct tcrypt_result *res = req->data;
|
|
||||||
|
|
||||||
if (err == -EINPROGRESS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
res->err = err;
|
|
||||||
complete(&res->completion);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int do_one_ahash_op(struct ahash_request *req, int ret)
|
static inline int do_one_ahash_op(struct ahash_request *req, int ret)
|
||||||
{
|
{
|
||||||
if (ret == -EINPROGRESS || ret == -EBUSY) {
|
if (ret == -EINPROGRESS || ret == -EBUSY) {
|
||||||
|
@ -1760,6 +1779,8 @@ static int do_test(const char *alg, u32 type, u32 mask, int m)
|
||||||
case 211:
|
case 211:
|
||||||
test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
|
test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
|
||||||
NULL, 0, 16, 8, aead_speed_template_20);
|
NULL, 0, 16, 8, aead_speed_template_20);
|
||||||
|
test_aead_speed("gcm(aes)", ENCRYPT, sec,
|
||||||
|
NULL, 0, 16, 8, aead_speed_template_20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 212:
|
case 212:
|
||||||
|
|
Loading…
Add table
Reference in a new issue