mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 07:31:41 +00:00
crypto: user - Split stats in multiple structures
Like for userspace, this patch splits stats into multiple structures, one for each algorithm class. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
5fff81729f
commit
17c18f9e33
3 changed files with 210 additions and 160 deletions
108
crypto/algapi.c
108
crypto/algapi.c
|
@ -259,13 +259,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
|
|||
list_add(&larval->alg.cra_list, &crypto_alg_list);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_STATS
|
||||
atomic64_set(&alg->encrypt_cnt, 0);
|
||||
atomic64_set(&alg->decrypt_cnt, 0);
|
||||
atomic64_set(&alg->encrypt_tlen, 0);
|
||||
atomic64_set(&alg->decrypt_tlen, 0);
|
||||
atomic64_set(&alg->verify_cnt, 0);
|
||||
atomic64_set(&alg->cipher_err_cnt, 0);
|
||||
atomic64_set(&alg->sign_cnt, 0);
|
||||
memset(&alg->stats, 0, sizeof(alg->stats));
|
||||
#endif
|
||||
|
||||
out:
|
||||
|
@ -1089,10 +1083,10 @@ void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->cipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.cipher.cipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->encrypt_cnt);
|
||||
atomic64_add(nbytes, &alg->encrypt_tlen);
|
||||
atomic64_inc(&alg->stats.cipher.encrypt_cnt);
|
||||
atomic64_add(nbytes, &alg->stats.cipher.encrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1102,10 +1096,10 @@ void crypto_stats_ablkcipher_decrypt(unsigned int nbytes, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->cipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.cipher.cipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->decrypt_cnt);
|
||||
atomic64_add(nbytes, &alg->decrypt_tlen);
|
||||
atomic64_inc(&alg->stats.cipher.decrypt_cnt);
|
||||
atomic64_add(nbytes, &alg->stats.cipher.decrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1115,10 +1109,10 @@ void crypto_stats_aead_encrypt(unsigned int cryptlen, struct crypto_alg *alg,
|
|||
int ret)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->aead_err_cnt);
|
||||
atomic64_inc(&alg->stats.aead.aead_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->encrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->encrypt_tlen);
|
||||
atomic64_inc(&alg->stats.aead.encrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->stats.aead.encrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1128,10 +1122,10 @@ void crypto_stats_aead_decrypt(unsigned int cryptlen, struct crypto_alg *alg,
|
|||
int ret)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->aead_err_cnt);
|
||||
atomic64_inc(&alg->stats.aead.aead_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->decrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->decrypt_tlen);
|
||||
atomic64_inc(&alg->stats.aead.decrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->stats.aead.decrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1141,10 +1135,10 @@ void crypto_stats_akcipher_encrypt(unsigned int src_len, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->akcipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->encrypt_cnt);
|
||||
atomic64_add(src_len, &alg->encrypt_tlen);
|
||||
atomic64_inc(&alg->stats.akcipher.encrypt_cnt);
|
||||
atomic64_add(src_len, &alg->stats.akcipher.encrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1154,10 +1148,10 @@ void crypto_stats_akcipher_decrypt(unsigned int src_len, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->akcipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->decrypt_cnt);
|
||||
atomic64_add(src_len, &alg->decrypt_tlen);
|
||||
atomic64_inc(&alg->stats.akcipher.decrypt_cnt);
|
||||
atomic64_add(src_len, &alg->stats.akcipher.decrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1166,9 +1160,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_decrypt);
|
|||
void crypto_stats_akcipher_sign(int ret, struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
||||
atomic64_inc(&alg->akcipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->sign_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.sign_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign);
|
||||
|
@ -1176,9 +1170,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign);
|
|||
void crypto_stats_akcipher_verify(int ret, struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
||||
atomic64_inc(&alg->akcipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->verify_cnt);
|
||||
atomic64_inc(&alg->stats.akcipher.verify_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify);
|
||||
|
@ -1186,10 +1180,10 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify);
|
|||
void crypto_stats_compress(unsigned int slen, int ret, struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->compress_err_cnt);
|
||||
atomic64_inc(&alg->stats.compress.compress_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->compress_cnt);
|
||||
atomic64_add(slen, &alg->compress_tlen);
|
||||
atomic64_inc(&alg->stats.compress.compress_cnt);
|
||||
atomic64_add(slen, &alg->stats.compress.compress_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1198,10 +1192,10 @@ EXPORT_SYMBOL_GPL(crypto_stats_compress);
|
|||
void crypto_stats_decompress(unsigned int slen, int ret, struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->compress_err_cnt);
|
||||
atomic64_inc(&alg->stats.compress.compress_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->decompress_cnt);
|
||||
atomic64_add(slen, &alg->decompress_tlen);
|
||||
atomic64_inc(&alg->stats.compress.decompress_cnt);
|
||||
atomic64_add(slen, &alg->stats.compress.decompress_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1211,9 +1205,9 @@ void crypto_stats_ahash_update(unsigned int nbytes, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
||||
atomic64_inc(&alg->hash_err_cnt);
|
||||
atomic64_inc(&alg->stats.hash.hash_err_cnt);
|
||||
else
|
||||
atomic64_add(nbytes, &alg->hash_tlen);
|
||||
atomic64_add(nbytes, &alg->stats.hash.hash_tlen);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_ahash_update);
|
||||
|
@ -1222,10 +1216,10 @@ void crypto_stats_ahash_final(unsigned int nbytes, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->hash_err_cnt);
|
||||
atomic64_inc(&alg->stats.hash.hash_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->hash_cnt);
|
||||
atomic64_add(nbytes, &alg->hash_tlen);
|
||||
atomic64_inc(&alg->stats.hash.hash_cnt);
|
||||
atomic64_add(nbytes, &alg->stats.hash.hash_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1234,9 +1228,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_ahash_final);
|
|||
void crypto_stats_kpp_set_secret(struct crypto_alg *alg, int ret)
|
||||
{
|
||||
if (ret)
|
||||
atomic64_inc(&alg->kpp_err_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.kpp_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->setsecret_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.setsecret_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret);
|
||||
|
@ -1244,9 +1238,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret);
|
|||
void crypto_stats_kpp_generate_public_key(struct crypto_alg *alg, int ret)
|
||||
{
|
||||
if (ret)
|
||||
atomic64_inc(&alg->kpp_err_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.kpp_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->generate_public_key_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.generate_public_key_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key);
|
||||
|
@ -1254,9 +1248,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key);
|
|||
void crypto_stats_kpp_compute_shared_secret(struct crypto_alg *alg, int ret)
|
||||
{
|
||||
if (ret)
|
||||
atomic64_inc(&alg->kpp_err_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.kpp_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->compute_shared_secret_cnt);
|
||||
atomic64_inc(&alg->stats.kpp.compute_shared_secret_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret);
|
||||
|
@ -1264,9 +1258,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret);
|
|||
void crypto_stats_rng_seed(struct crypto_alg *alg, int ret)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY)
|
||||
atomic64_inc(&alg->rng_err_cnt);
|
||||
atomic64_inc(&alg->stats.rng.rng_err_cnt);
|
||||
else
|
||||
atomic64_inc(&alg->seed_cnt);
|
||||
atomic64_inc(&alg->stats.rng.seed_cnt);
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_stats_rng_seed);
|
||||
|
@ -1275,10 +1269,10 @@ void crypto_stats_rng_generate(struct crypto_alg *alg, unsigned int dlen,
|
|||
int ret)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->rng_err_cnt);
|
||||
atomic64_inc(&alg->stats.rng.rng_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->generate_cnt);
|
||||
atomic64_add(dlen, &alg->generate_tlen);
|
||||
atomic64_inc(&alg->stats.rng.generate_cnt);
|
||||
atomic64_add(dlen, &alg->stats.rng.generate_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1288,10 +1282,10 @@ void crypto_stats_skcipher_encrypt(unsigned int cryptlen, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->cipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.cipher.cipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->encrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->encrypt_tlen);
|
||||
atomic64_inc(&alg->stats.cipher.encrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->stats.cipher.encrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
@ -1301,10 +1295,10 @@ void crypto_stats_skcipher_decrypt(unsigned int cryptlen, int ret,
|
|||
struct crypto_alg *alg)
|
||||
{
|
||||
if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
|
||||
atomic64_inc(&alg->cipher_err_cnt);
|
||||
atomic64_inc(&alg->stats.cipher.cipher_err_cnt);
|
||||
} else {
|
||||
atomic64_inc(&alg->decrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->decrypt_tlen);
|
||||
atomic64_inc(&alg->stats.cipher.decrypt_cnt);
|
||||
atomic64_add(cryptlen, &alg->stats.cipher.decrypt_tlen);
|
||||
}
|
||||
crypto_alg_put(alg);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue