diff options
author | Corentin Labbe <clabbe@baylibre.com> | 2018-11-29 09:42:24 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-12-07 01:15:00 -0500 |
commit | 17c18f9e33282a170458cb5ea20759bfcb0da7d8 (patch) | |
tree | 13e2b9bc7500fa81695018e29616f1efa4a3243b | |
parent | 5fff81729f09f3d7d9be0ace50be112bd34f0bb9 (diff) |
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>
-rw-r--r-- | crypto/algapi.c | 108 | ||||
-rw-r--r-- | crypto/crypto_user_stat.c | 82 | ||||
-rw-r--r-- | include/linux/crypto.h | 180 |
3 files changed, 210 insertions, 160 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 4c1e6079d271..a8cb5aed0069 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -259,13 +259,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) | |||
259 | list_add(&larval->alg.cra_list, &crypto_alg_list); | 259 | list_add(&larval->alg.cra_list, &crypto_alg_list); |
260 | 260 | ||
261 | #ifdef CONFIG_CRYPTO_STATS | 261 | #ifdef CONFIG_CRYPTO_STATS |
262 | atomic64_set(&alg->encrypt_cnt, 0); | 262 | memset(&alg->stats, 0, sizeof(alg->stats)); |
263 | atomic64_set(&alg->decrypt_cnt, 0); | ||
264 | atomic64_set(&alg->encrypt_tlen, 0); | ||
265 | atomic64_set(&alg->decrypt_tlen, 0); | ||
266 | atomic64_set(&alg->verify_cnt, 0); | ||
267 | atomic64_set(&alg->cipher_err_cnt, 0); | ||
268 | atomic64_set(&alg->sign_cnt, 0); | ||
269 | #endif | 263 | #endif |
270 | 264 | ||
271 | out: | 265 | out: |
@@ -1089,10 +1083,10 @@ void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret, | |||
1089 | struct crypto_alg *alg) | 1083 | struct crypto_alg *alg) |
1090 | { | 1084 | { |
1091 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1085 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1092 | atomic64_inc(&alg->cipher_err_cnt); | 1086 | atomic64_inc(&alg->stats.cipher.cipher_err_cnt); |
1093 | } else { | 1087 | } else { |
1094 | atomic64_inc(&alg->encrypt_cnt); | 1088 | atomic64_inc(&alg->stats.cipher.encrypt_cnt); |
1095 | atomic64_add(nbytes, &alg->encrypt_tlen); | 1089 | atomic64_add(nbytes, &alg->stats.cipher.encrypt_tlen); |
1096 | } | 1090 | } |
1097 | crypto_alg_put(alg); | 1091 | crypto_alg_put(alg); |
1098 | } | 1092 | } |
@@ -1102,10 +1096,10 @@ void crypto_stats_ablkcipher_decrypt(unsigned int nbytes, int ret, | |||
1102 | struct crypto_alg *alg) | 1096 | struct crypto_alg *alg) |
1103 | { | 1097 | { |
1104 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1098 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1105 | atomic64_inc(&alg->cipher_err_cnt); | 1099 | atomic64_inc(&alg->stats.cipher.cipher_err_cnt); |
1106 | } else { | 1100 | } else { |
1107 | atomic64_inc(&alg->decrypt_cnt); | 1101 | atomic64_inc(&alg->stats.cipher.decrypt_cnt); |
1108 | atomic64_add(nbytes, &alg->decrypt_tlen); | 1102 | atomic64_add(nbytes, &alg->stats.cipher.decrypt_tlen); |
1109 | } | 1103 | } |
1110 | crypto_alg_put(alg); | 1104 | crypto_alg_put(alg); |
1111 | } | 1105 | } |
@@ -1115,10 +1109,10 @@ void crypto_stats_aead_encrypt(unsigned int cryptlen, struct crypto_alg *alg, | |||
1115 | int ret) | 1109 | int ret) |
1116 | { | 1110 | { |
1117 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1111 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1118 | atomic64_inc(&alg->aead_err_cnt); | 1112 | atomic64_inc(&alg->stats.aead.aead_err_cnt); |
1119 | } else { | 1113 | } else { |
1120 | atomic64_inc(&alg->encrypt_cnt); | 1114 | atomic64_inc(&alg->stats.aead.encrypt_cnt); |
1121 | atomic64_add(cryptlen, &alg->encrypt_tlen); | 1115 | atomic64_add(cryptlen, &alg->stats.aead.encrypt_tlen); |
1122 | } | 1116 | } |
1123 | crypto_alg_put(alg); | 1117 | crypto_alg_put(alg); |
1124 | } | 1118 | } |
@@ -1128,10 +1122,10 @@ void crypto_stats_aead_decrypt(unsigned int cryptlen, struct crypto_alg *alg, | |||
1128 | int ret) | 1122 | int ret) |
1129 | { | 1123 | { |
1130 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1124 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1131 | atomic64_inc(&alg->aead_err_cnt); | 1125 | atomic64_inc(&alg->stats.aead.aead_err_cnt); |
1132 | } else { | 1126 | } else { |
1133 | atomic64_inc(&alg->decrypt_cnt); | 1127 | atomic64_inc(&alg->stats.aead.decrypt_cnt); |
1134 | atomic64_add(cryptlen, &alg->decrypt_tlen); | 1128 | atomic64_add(cryptlen, &alg->stats.aead.decrypt_tlen); |
1135 | } | 1129 | } |
1136 | crypto_alg_put(alg); | 1130 | crypto_alg_put(alg); |
1137 | } | 1131 | } |
@@ -1141,10 +1135,10 @@ void crypto_stats_akcipher_encrypt(unsigned int src_len, int ret, | |||
1141 | struct crypto_alg *alg) | 1135 | struct crypto_alg *alg) |
1142 | { | 1136 | { |
1143 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1137 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1144 | atomic64_inc(&alg->akcipher_err_cnt); | 1138 | atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt); |
1145 | } else { | 1139 | } else { |
1146 | atomic64_inc(&alg->encrypt_cnt); | 1140 | atomic64_inc(&alg->stats.akcipher.encrypt_cnt); |
1147 | atomic64_add(src_len, &alg->encrypt_tlen); | 1141 | atomic64_add(src_len, &alg->stats.akcipher.encrypt_tlen); |
1148 | } | 1142 | } |
1149 | crypto_alg_put(alg); | 1143 | crypto_alg_put(alg); |
1150 | } | 1144 | } |
@@ -1154,10 +1148,10 @@ void crypto_stats_akcipher_decrypt(unsigned int src_len, int ret, | |||
1154 | struct crypto_alg *alg) | 1148 | struct crypto_alg *alg) |
1155 | { | 1149 | { |
1156 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1150 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1157 | atomic64_inc(&alg->akcipher_err_cnt); | 1151 | atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt); |
1158 | } else { | 1152 | } else { |
1159 | atomic64_inc(&alg->decrypt_cnt); | 1153 | atomic64_inc(&alg->stats.akcipher.decrypt_cnt); |
1160 | atomic64_add(src_len, &alg->decrypt_tlen); | 1154 | atomic64_add(src_len, &alg->stats.akcipher.decrypt_tlen); |
1161 | } | 1155 | } |
1162 | crypto_alg_put(alg); | 1156 | crypto_alg_put(alg); |
1163 | } | 1157 | } |
@@ -1166,9 +1160,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_decrypt); | |||
1166 | void crypto_stats_akcipher_sign(int ret, struct crypto_alg *alg) | 1160 | void crypto_stats_akcipher_sign(int ret, struct crypto_alg *alg) |
1167 | { | 1161 | { |
1168 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) | 1162 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) |
1169 | atomic64_inc(&alg->akcipher_err_cnt); | 1163 | atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt); |
1170 | else | 1164 | else |
1171 | atomic64_inc(&alg->sign_cnt); | 1165 | atomic64_inc(&alg->stats.akcipher.sign_cnt); |
1172 | crypto_alg_put(alg); | 1166 | crypto_alg_put(alg); |
1173 | } | 1167 | } |
1174 | EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign); | 1168 | EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign); |
@@ -1176,9 +1170,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_sign); | |||
1176 | void crypto_stats_akcipher_verify(int ret, struct crypto_alg *alg) | 1170 | void crypto_stats_akcipher_verify(int ret, struct crypto_alg *alg) |
1177 | { | 1171 | { |
1178 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) | 1172 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) |
1179 | atomic64_inc(&alg->akcipher_err_cnt); | 1173 | atomic64_inc(&alg->stats.akcipher.akcipher_err_cnt); |
1180 | else | 1174 | else |
1181 | atomic64_inc(&alg->verify_cnt); | 1175 | atomic64_inc(&alg->stats.akcipher.verify_cnt); |
1182 | crypto_alg_put(alg); | 1176 | crypto_alg_put(alg); |
1183 | } | 1177 | } |
1184 | EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify); | 1178 | EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify); |
@@ -1186,10 +1180,10 @@ EXPORT_SYMBOL_GPL(crypto_stats_akcipher_verify); | |||
1186 | void crypto_stats_compress(unsigned int slen, int ret, struct crypto_alg *alg) | 1180 | void crypto_stats_compress(unsigned int slen, int ret, struct crypto_alg *alg) |
1187 | { | 1181 | { |
1188 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1182 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1189 | atomic64_inc(&alg->compress_err_cnt); | 1183 | atomic64_inc(&alg->stats.compress.compress_err_cnt); |
1190 | } else { | 1184 | } else { |
1191 | atomic64_inc(&alg->compress_cnt); | 1185 | atomic64_inc(&alg->stats.compress.compress_cnt); |
1192 | atomic64_add(slen, &alg->compress_tlen); | 1186 | atomic64_add(slen, &alg->stats.compress.compress_tlen); |
1193 | } | 1187 | } |
1194 | crypto_alg_put(alg); | 1188 | crypto_alg_put(alg); |
1195 | } | 1189 | } |
@@ -1198,10 +1192,10 @@ EXPORT_SYMBOL_GPL(crypto_stats_compress); | |||
1198 | void crypto_stats_decompress(unsigned int slen, int ret, struct crypto_alg *alg) | 1192 | void crypto_stats_decompress(unsigned int slen, int ret, struct crypto_alg *alg) |
1199 | { | 1193 | { |
1200 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1194 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1201 | atomic64_inc(&alg->compress_err_cnt); | 1195 | atomic64_inc(&alg->stats.compress.compress_err_cnt); |
1202 | } else { | 1196 | } else { |
1203 | atomic64_inc(&alg->decompress_cnt); | 1197 | atomic64_inc(&alg->stats.compress.decompress_cnt); |
1204 | atomic64_add(slen, &alg->decompress_tlen); | 1198 | atomic64_add(slen, &alg->stats.compress.decompress_tlen); |
1205 | } | 1199 | } |
1206 | crypto_alg_put(alg); | 1200 | crypto_alg_put(alg); |
1207 | } | 1201 | } |
@@ -1211,9 +1205,9 @@ void crypto_stats_ahash_update(unsigned int nbytes, int ret, | |||
1211 | struct crypto_alg *alg) | 1205 | struct crypto_alg *alg) |
1212 | { | 1206 | { |
1213 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) | 1207 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) |
1214 | atomic64_inc(&alg->hash_err_cnt); | 1208 | atomic64_inc(&alg->stats.hash.hash_err_cnt); |
1215 | else | 1209 | else |
1216 | atomic64_add(nbytes, &alg->hash_tlen); | 1210 | atomic64_add(nbytes, &alg->stats.hash.hash_tlen); |
1217 | crypto_alg_put(alg); | 1211 | crypto_alg_put(alg); |
1218 | } | 1212 | } |
1219 | EXPORT_SYMBOL_GPL(crypto_stats_ahash_update); | 1213 | EXPORT_SYMBOL_GPL(crypto_stats_ahash_update); |
@@ -1222,10 +1216,10 @@ void crypto_stats_ahash_final(unsigned int nbytes, int ret, | |||
1222 | struct crypto_alg *alg) | 1216 | struct crypto_alg *alg) |
1223 | { | 1217 | { |
1224 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1218 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1225 | atomic64_inc(&alg->hash_err_cnt); | 1219 | atomic64_inc(&alg->stats.hash.hash_err_cnt); |
1226 | } else { | 1220 | } else { |
1227 | atomic64_inc(&alg->hash_cnt); | 1221 | atomic64_inc(&alg->stats.hash.hash_cnt); |
1228 | atomic64_add(nbytes, &alg->hash_tlen); | 1222 | atomic64_add(nbytes, &alg->stats.hash.hash_tlen); |
1229 | } | 1223 | } |
1230 | crypto_alg_put(alg); | 1224 | crypto_alg_put(alg); |
1231 | } | 1225 | } |
@@ -1234,9 +1228,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_ahash_final); | |||
1234 | void crypto_stats_kpp_set_secret(struct crypto_alg *alg, int ret) | 1228 | void crypto_stats_kpp_set_secret(struct crypto_alg *alg, int ret) |
1235 | { | 1229 | { |
1236 | if (ret) | 1230 | if (ret) |
1237 | atomic64_inc(&alg->kpp_err_cnt); | 1231 | atomic64_inc(&alg->stats.kpp.kpp_err_cnt); |
1238 | else | 1232 | else |
1239 | atomic64_inc(&alg->setsecret_cnt); | 1233 | atomic64_inc(&alg->stats.kpp.setsecret_cnt); |
1240 | crypto_alg_put(alg); | 1234 | crypto_alg_put(alg); |
1241 | } | 1235 | } |
1242 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret); | 1236 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret); |
@@ -1244,9 +1238,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_set_secret); | |||
1244 | void crypto_stats_kpp_generate_public_key(struct crypto_alg *alg, int ret) | 1238 | void crypto_stats_kpp_generate_public_key(struct crypto_alg *alg, int ret) |
1245 | { | 1239 | { |
1246 | if (ret) | 1240 | if (ret) |
1247 | atomic64_inc(&alg->kpp_err_cnt); | 1241 | atomic64_inc(&alg->stats.kpp.kpp_err_cnt); |
1248 | else | 1242 | else |
1249 | atomic64_inc(&alg->generate_public_key_cnt); | 1243 | atomic64_inc(&alg->stats.kpp.generate_public_key_cnt); |
1250 | crypto_alg_put(alg); | 1244 | crypto_alg_put(alg); |
1251 | } | 1245 | } |
1252 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key); | 1246 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key); |
@@ -1254,9 +1248,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_generate_public_key); | |||
1254 | void crypto_stats_kpp_compute_shared_secret(struct crypto_alg *alg, int ret) | 1248 | void crypto_stats_kpp_compute_shared_secret(struct crypto_alg *alg, int ret) |
1255 | { | 1249 | { |
1256 | if (ret) | 1250 | if (ret) |
1257 | atomic64_inc(&alg->kpp_err_cnt); | 1251 | atomic64_inc(&alg->stats.kpp.kpp_err_cnt); |
1258 | else | 1252 | else |
1259 | atomic64_inc(&alg->compute_shared_secret_cnt); | 1253 | atomic64_inc(&alg->stats.kpp.compute_shared_secret_cnt); |
1260 | crypto_alg_put(alg); | 1254 | crypto_alg_put(alg); |
1261 | } | 1255 | } |
1262 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret); | 1256 | EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret); |
@@ -1264,9 +1258,9 @@ EXPORT_SYMBOL_GPL(crypto_stats_kpp_compute_shared_secret); | |||
1264 | void crypto_stats_rng_seed(struct crypto_alg *alg, int ret) | 1258 | void crypto_stats_rng_seed(struct crypto_alg *alg, int ret) |
1265 | { | 1259 | { |
1266 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) | 1260 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) |
1267 | atomic64_inc(&alg->rng_err_cnt); | 1261 | atomic64_inc(&alg->stats.rng.rng_err_cnt); |
1268 | else | 1262 | else |
1269 | atomic64_inc(&alg->seed_cnt); | 1263 | atomic64_inc(&alg->stats.rng.seed_cnt); |
1270 | crypto_alg_put(alg); | 1264 | crypto_alg_put(alg); |
1271 | } | 1265 | } |
1272 | EXPORT_SYMBOL_GPL(crypto_stats_rng_seed); | 1266 | EXPORT_SYMBOL_GPL(crypto_stats_rng_seed); |
@@ -1275,10 +1269,10 @@ void crypto_stats_rng_generate(struct crypto_alg *alg, unsigned int dlen, | |||
1275 | int ret) | 1269 | int ret) |
1276 | { | 1270 | { |
1277 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1271 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1278 | atomic64_inc(&alg->rng_err_cnt); | 1272 | atomic64_inc(&alg->stats.rng.rng_err_cnt); |
1279 | } else { | 1273 | } else { |
1280 | atomic64_inc(&alg->generate_cnt); | 1274 | atomic64_inc(&alg->stats.rng.generate_cnt); |
1281 | atomic64_add(dlen, &alg->generate_tlen); | 1275 | atomic64_add(dlen, &alg->stats.rng.generate_tlen); |
1282 | } | 1276 | } |
1283 | crypto_alg_put(alg); | 1277 | crypto_alg_put(alg); |
1284 | } | 1278 | } |
@@ -1288,10 +1282,10 @@ void crypto_stats_skcipher_encrypt(unsigned int cryptlen, int ret, | |||
1288 | struct crypto_alg *alg) | 1282 | struct crypto_alg *alg) |
1289 | { | 1283 | { |
1290 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1284 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1291 | atomic64_inc(&alg->cipher_err_cnt); | 1285 | atomic64_inc(&alg->stats.cipher.cipher_err_cnt); |
1292 | } else { | 1286 | } else { |
1293 | atomic64_inc(&alg->encrypt_cnt); | 1287 | atomic64_inc(&alg->stats.cipher.encrypt_cnt); |
1294 | atomic64_add(cryptlen, &alg->encrypt_tlen); | 1288 | atomic64_add(cryptlen, &alg->stats.cipher.encrypt_tlen); |
1295 | } | 1289 | } |
1296 | crypto_alg_put(alg); | 1290 | crypto_alg_put(alg); |
1297 | } | 1291 | } |
@@ -1301,10 +1295,10 @@ void crypto_stats_skcipher_decrypt(unsigned int cryptlen, int ret, | |||
1301 | struct crypto_alg *alg) | 1295 | struct crypto_alg *alg) |
1302 | { | 1296 | { |
1303 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { | 1297 | if (ret && ret != -EINPROGRESS && ret != -EBUSY) { |
1304 | atomic64_inc(&alg->cipher_err_cnt); | 1298 | atomic64_inc(&alg->stats.cipher.cipher_err_cnt); |
1305 | } else { | 1299 | } else { |
1306 | atomic64_inc(&alg->decrypt_cnt); | 1300 | atomic64_inc(&alg->stats.cipher.decrypt_cnt); |
1307 | atomic64_add(cryptlen, &alg->decrypt_tlen); | 1301 | atomic64_add(cryptlen, &alg->stats.cipher.decrypt_tlen); |
1308 | } | 1302 | } |
1309 | crypto_alg_put(alg); | 1303 | crypto_alg_put(alg); |
1310 | } | 1304 | } |
diff --git a/crypto/crypto_user_stat.c b/crypto/crypto_user_stat.c index 7b668c659122..113bf1691560 100644 --- a/crypto/crypto_user_stat.c +++ b/crypto/crypto_user_stat.c | |||
@@ -39,11 +39,11 @@ static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg) | |||
39 | 39 | ||
40 | strscpy(raead.type, "aead", sizeof(raead.type)); | 40 | strscpy(raead.type, "aead", sizeof(raead.type)); |
41 | 41 | ||
42 | raead.stat_encrypt_cnt = atomic64_read(&alg->encrypt_cnt); | 42 | raead.stat_encrypt_cnt = atomic64_read(&alg->stats.aead.encrypt_cnt); |
43 | raead.stat_encrypt_tlen = atomic64_read(&alg->encrypt_tlen); | 43 | raead.stat_encrypt_tlen = atomic64_read(&alg->stats.aead.encrypt_tlen); |
44 | raead.stat_decrypt_cnt = atomic64_read(&alg->decrypt_cnt); | 44 | raead.stat_decrypt_cnt = atomic64_read(&alg->stats.aead.decrypt_cnt); |
45 | raead.stat_decrypt_tlen = atomic64_read(&alg->decrypt_tlen); | 45 | raead.stat_decrypt_tlen = atomic64_read(&alg->stats.aead.decrypt_tlen); |
46 | raead.stat_aead_err_cnt = atomic64_read(&alg->aead_err_cnt); | 46 | raead.stat_aead_err_cnt = atomic64_read(&alg->stats.aead.aead_err_cnt); |
47 | 47 | ||
48 | return nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead); | 48 | return nla_put(skb, CRYPTOCFGA_STAT_AEAD, sizeof(raead), &raead); |
49 | } | 49 | } |
@@ -56,11 +56,11 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg) | |||
56 | 56 | ||
57 | strscpy(rcipher.type, "cipher", sizeof(rcipher.type)); | 57 | strscpy(rcipher.type, "cipher", sizeof(rcipher.type)); |
58 | 58 | ||
59 | rcipher.stat_encrypt_cnt = atomic64_read(&alg->encrypt_cnt); | 59 | rcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.cipher.encrypt_cnt); |
60 | rcipher.stat_encrypt_tlen = atomic64_read(&alg->encrypt_tlen); | 60 | rcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.cipher.encrypt_tlen); |
61 | rcipher.stat_decrypt_cnt = atomic64_read(&alg->decrypt_cnt); | 61 | rcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.cipher.decrypt_cnt); |
62 | rcipher.stat_decrypt_tlen = atomic64_read(&alg->decrypt_tlen); | 62 | rcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.cipher.decrypt_tlen); |
63 | rcipher.stat_cipher_err_cnt = atomic64_read(&alg->cipher_err_cnt); | 63 | rcipher.stat_cipher_err_cnt = atomic64_read(&alg->stats.cipher.cipher_err_cnt); |
64 | 64 | ||
65 | return nla_put(skb, CRYPTOCFGA_STAT_CIPHER, sizeof(rcipher), &rcipher); | 65 | return nla_put(skb, CRYPTOCFGA_STAT_CIPHER, sizeof(rcipher), &rcipher); |
66 | } | 66 | } |
@@ -72,11 +72,11 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg) | |||
72 | memset(&rcomp, 0, sizeof(rcomp)); | 72 | memset(&rcomp, 0, sizeof(rcomp)); |
73 | 73 | ||
74 | strscpy(rcomp.type, "compression", sizeof(rcomp.type)); | 74 | strscpy(rcomp.type, "compression", sizeof(rcomp.type)); |
75 | rcomp.stat_compress_cnt = atomic64_read(&alg->compress_cnt); | 75 | rcomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt); |
76 | rcomp.stat_compress_tlen = atomic64_read(&alg->compress_tlen); | 76 | rcomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen); |
77 | rcomp.stat_decompress_cnt = atomic64_read(&alg->decompress_cnt); | 77 | rcomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt); |
78 | rcomp.stat_decompress_tlen = atomic64_read(&alg->decompress_tlen); | 78 | rcomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen); |
79 | rcomp.stat_compress_err_cnt = atomic64_read(&alg->compress_err_cnt); | 79 | rcomp.stat_compress_err_cnt = atomic64_read(&alg->stats.compress.compress_err_cnt); |
80 | 80 | ||
81 | return nla_put(skb, CRYPTOCFGA_STAT_COMPRESS, sizeof(rcomp), &rcomp); | 81 | return nla_put(skb, CRYPTOCFGA_STAT_COMPRESS, sizeof(rcomp), &rcomp); |
82 | } | 82 | } |
@@ -88,11 +88,11 @@ static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg) | |||
88 | memset(&racomp, 0, sizeof(racomp)); | 88 | memset(&racomp, 0, sizeof(racomp)); |
89 | 89 | ||
90 | strscpy(racomp.type, "acomp", sizeof(racomp.type)); | 90 | strscpy(racomp.type, "acomp", sizeof(racomp.type)); |
91 | racomp.stat_compress_cnt = atomic64_read(&alg->compress_cnt); | 91 | racomp.stat_compress_cnt = atomic64_read(&alg->stats.compress.compress_cnt); |
92 | racomp.stat_compress_tlen = atomic64_read(&alg->compress_tlen); | 92 | racomp.stat_compress_tlen = atomic64_read(&alg->stats.compress.compress_tlen); |
93 | racomp.stat_decompress_cnt = atomic64_read(&alg->decompress_cnt); | 93 | racomp.stat_decompress_cnt = atomic64_read(&alg->stats.compress.decompress_cnt); |
94 | racomp.stat_decompress_tlen = atomic64_read(&alg->decompress_tlen); | 94 | racomp.stat_decompress_tlen = atomic64_read(&alg->stats.compress.decompress_tlen); |
95 | racomp.stat_compress_err_cnt = atomic64_read(&alg->compress_err_cnt); | 95 | racomp.stat_compress_err_cnt = atomic64_read(&alg->stats.compress.compress_err_cnt); |
96 | 96 | ||
97 | return nla_put(skb, CRYPTOCFGA_STAT_ACOMP, sizeof(racomp), &racomp); | 97 | return nla_put(skb, CRYPTOCFGA_STAT_ACOMP, sizeof(racomp), &racomp); |
98 | } | 98 | } |
@@ -104,13 +104,13 @@ static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg) | |||
104 | memset(&rakcipher, 0, sizeof(rakcipher)); | 104 | memset(&rakcipher, 0, sizeof(rakcipher)); |
105 | 105 | ||
106 | strscpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); | 106 | strscpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); |
107 | rakcipher.stat_encrypt_cnt = atomic64_read(&alg->encrypt_cnt); | 107 | rakcipher.stat_encrypt_cnt = atomic64_read(&alg->stats.akcipher.encrypt_cnt); |
108 | rakcipher.stat_encrypt_tlen = atomic64_read(&alg->encrypt_tlen); | 108 | rakcipher.stat_encrypt_tlen = atomic64_read(&alg->stats.akcipher.encrypt_tlen); |
109 | rakcipher.stat_decrypt_cnt = atomic64_read(&alg->decrypt_cnt); | 109 | rakcipher.stat_decrypt_cnt = atomic64_read(&alg->stats.akcipher.decrypt_cnt); |
110 | rakcipher.stat_decrypt_tlen = atomic64_read(&alg->decrypt_tlen); | 110 | rakcipher.stat_decrypt_tlen = atomic64_read(&alg->stats.akcipher.decrypt_tlen); |
111 | rakcipher.stat_sign_cnt = atomic64_read(&alg->sign_cnt); | 111 | rakcipher.stat_sign_cnt = atomic64_read(&alg->stats.akcipher.sign_cnt); |
112 | rakcipher.stat_verify_cnt = atomic64_read(&alg->verify_cnt); | 112 | rakcipher.stat_verify_cnt = atomic64_read(&alg->stats.akcipher.verify_cnt); |
113 | rakcipher.stat_akcipher_err_cnt = atomic64_read(&alg->akcipher_err_cnt); | 113 | rakcipher.stat_akcipher_err_cnt = atomic64_read(&alg->stats.akcipher.akcipher_err_cnt); |
114 | 114 | ||
115 | return nla_put(skb, CRYPTOCFGA_STAT_AKCIPHER, | 115 | return nla_put(skb, CRYPTOCFGA_STAT_AKCIPHER, |
116 | sizeof(rakcipher), &rakcipher); | 116 | sizeof(rakcipher), &rakcipher); |
@@ -124,10 +124,10 @@ static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg) | |||
124 | 124 | ||
125 | strscpy(rkpp.type, "kpp", sizeof(rkpp.type)); | 125 | strscpy(rkpp.type, "kpp", sizeof(rkpp.type)); |
126 | 126 | ||
127 | rkpp.stat_setsecret_cnt = atomic64_read(&alg->setsecret_cnt); | 127 | rkpp.stat_setsecret_cnt = atomic64_read(&alg->stats.kpp.setsecret_cnt); |
128 | rkpp.stat_generate_public_key_cnt = atomic64_read(&alg->generate_public_key_cnt); | 128 | rkpp.stat_generate_public_key_cnt = atomic64_read(&alg->stats.kpp.generate_public_key_cnt); |
129 | rkpp.stat_compute_shared_secret_cnt = atomic64_read(&alg->compute_shared_secret_cnt); | 129 | rkpp.stat_compute_shared_secret_cnt = atomic64_read(&alg->stats.kpp.compute_shared_secret_cnt); |
130 | rkpp.stat_kpp_err_cnt = atomic64_read(&alg->kpp_err_cnt); | 130 | rkpp.stat_kpp_err_cnt = atomic64_read(&alg->stats.kpp.kpp_err_cnt); |
131 | 131 | ||
132 | return nla_put(skb, CRYPTOCFGA_STAT_KPP, sizeof(rkpp), &rkpp); | 132 | return nla_put(skb, CRYPTOCFGA_STAT_KPP, sizeof(rkpp), &rkpp); |
133 | } | 133 | } |
@@ -140,9 +140,9 @@ static int crypto_report_ahash(struct sk_buff *skb, struct crypto_alg *alg) | |||
140 | 140 | ||
141 | strscpy(rhash.type, "ahash", sizeof(rhash.type)); | 141 | strscpy(rhash.type, "ahash", sizeof(rhash.type)); |
142 | 142 | ||
143 | rhash.stat_hash_cnt = atomic64_read(&alg->hash_cnt); | 143 | rhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt); |
144 | rhash.stat_hash_tlen = atomic64_read(&alg->hash_tlen); | 144 | rhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen); |
145 | rhash.stat_hash_err_cnt = atomic64_read(&alg->hash_err_cnt); | 145 | rhash.stat_hash_err_cnt = atomic64_read(&alg->stats.hash.hash_err_cnt); |
146 | 146 | ||
147 | return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash); | 147 | return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash); |
148 | } | 148 | } |
@@ -155,9 +155,9 @@ static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg) | |||
155 | 155 | ||
156 | strscpy(rhash.type, "shash", sizeof(rhash.type)); | 156 | strscpy(rhash.type, "shash", sizeof(rhash.type)); |
157 | 157 | ||
158 | rhash.stat_hash_cnt = atomic64_read(&alg->hash_cnt); | 158 | rhash.stat_hash_cnt = atomic64_read(&alg->stats.hash.hash_cnt); |
159 | rhash.stat_hash_tlen = atomic64_read(&alg->hash_tlen); | 159 | rhash.stat_hash_tlen = atomic64_read(&alg->stats.hash.hash_tlen); |
160 | rhash.stat_hash_err_cnt = atomic64_read(&alg->hash_err_cnt); | 160 | rhash.stat_hash_err_cnt = atomic64_read(&alg->stats.hash.hash_err_cnt); |
161 | 161 | ||
162 | return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash); | 162 | return nla_put(skb, CRYPTOCFGA_STAT_HASH, sizeof(rhash), &rhash); |
163 | } | 163 | } |
@@ -170,10 +170,10 @@ static int crypto_report_rng(struct sk_buff *skb, struct crypto_alg *alg) | |||
170 | 170 | ||
171 | strscpy(rrng.type, "rng", sizeof(rrng.type)); | 171 | strscpy(rrng.type, "rng", sizeof(rrng.type)); |
172 | 172 | ||
173 | rrng.stat_generate_cnt = atomic64_read(&alg->generate_cnt); | 173 | rrng.stat_generate_cnt = atomic64_read(&alg->stats.rng.generate_cnt); |
174 | rrng.stat_generate_tlen = atomic64_read(&alg->generate_tlen); | 174 | rrng.stat_generate_tlen = atomic64_read(&alg->stats.rng.generate_tlen); |
175 | rrng.stat_seed_cnt = atomic64_read(&alg->seed_cnt); | 175 | rrng.stat_seed_cnt = atomic64_read(&alg->stats.rng.seed_cnt); |
176 | rrng.stat_rng_err_cnt = atomic64_read(&alg->rng_err_cnt); | 176 | rrng.stat_rng_err_cnt = atomic64_read(&alg->stats.rng.rng_err_cnt); |
177 | 177 | ||
178 | return nla_put(skb, CRYPTOCFGA_STAT_RNG, sizeof(rrng), &rrng); | 178 | return nla_put(skb, CRYPTOCFGA_STAT_RNG, sizeof(rrng), &rrng); |
179 | } | 179 | } |
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index e2fd24714e00..8a46ab35479e 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -369,6 +369,115 @@ struct compress_alg { | |||
369 | unsigned int slen, u8 *dst, unsigned int *dlen); | 369 | unsigned int slen, u8 *dst, unsigned int *dlen); |
370 | }; | 370 | }; |
371 | 371 | ||
372 | #ifdef CONFIG_CRYPTO_STATS | ||
373 | /* | ||
374 | * struct crypto_istat_aead - statistics for AEAD algorithm | ||
375 | * @encrypt_cnt: number of encrypt requests | ||
376 | * @encrypt_tlen: total data size handled by encrypt requests | ||
377 | * @decrypt_cnt: number of decrypt requests | ||
378 | * @decrypt_tlen: total data size handled by decrypt requests | ||
379 | * @aead_err_cnt: number of error for AEAD requests | ||
380 | */ | ||
381 | struct crypto_istat_aead { | ||
382 | atomic64_t encrypt_cnt; | ||
383 | atomic64_t encrypt_tlen; | ||
384 | atomic64_t decrypt_cnt; | ||
385 | atomic64_t decrypt_tlen; | ||
386 | atomic64_t aead_err_cnt; | ||
387 | }; | ||
388 | |||
389 | /* | ||
390 | * struct crypto_istat_akcipher - statistics for akcipher algorithm | ||
391 | * @encrypt_cnt: number of encrypt requests | ||
392 | * @encrypt_tlen: total data size handled by encrypt requests | ||
393 | * @decrypt_cnt: number of decrypt requests | ||
394 | * @decrypt_tlen: total data size handled by decrypt requests | ||
395 | * @verify_cnt: number of verify operation | ||
396 | * @sign_cnt: number of sign requests | ||
397 | * @akcipher_err_cnt: number of error for akcipher requests | ||
398 | */ | ||
399 | struct crypto_istat_akcipher { | ||
400 | atomic64_t encrypt_cnt; | ||
401 | atomic64_t encrypt_tlen; | ||
402 | atomic64_t decrypt_cnt; | ||
403 | atomic64_t decrypt_tlen; | ||
404 | atomic64_t verify_cnt; | ||
405 | atomic64_t sign_cnt; | ||
406 | atomic64_t akcipher_err_cnt; | ||
407 | }; | ||
408 | |||
409 | /* | ||
410 | * struct crypto_istat_cipher - statistics for cipher algorithm | ||
411 | * @encrypt_cnt: number of encrypt requests | ||
412 | * @encrypt_tlen: total data size handled by encrypt requests | ||
413 | * @decrypt_cnt: number of decrypt requests | ||
414 | * @decrypt_tlen: total data size handled by decrypt requests | ||
415 | * @cipher_err_cnt: number of error for cipher requests | ||
416 | */ | ||
417 | struct crypto_istat_cipher { | ||
418 | atomic64_t encrypt_cnt; | ||
419 | atomic64_t encrypt_tlen; | ||
420 | atomic64_t decrypt_cnt; | ||
421 | atomic64_t decrypt_tlen; | ||
422 | atomic64_t cipher_err_cnt; | ||
423 | }; | ||
424 | |||
425 | /* | ||
426 | * struct crypto_istat_compress - statistics for compress algorithm | ||
427 | * @compress_cnt: number of compress requests | ||
428 | * @compress_tlen: total data size handled by compress requests | ||
429 | * @decompress_cnt: number of decompress requests | ||
430 | * @decompress_tlen: total data size handled by decompress requests | ||
431 | * @compress_err_cnt: number of error for compress requests | ||
432 | */ | ||
433 | struct crypto_istat_compress { | ||
434 | atomic64_t compress_cnt; | ||
435 | atomic64_t compress_tlen; | ||
436 | atomic64_t decompress_cnt; | ||
437 | atomic64_t decompress_tlen; | ||
438 | atomic64_t compress_err_cnt; | ||
439 | }; | ||
440 | |||
441 | /* | ||
442 | * struct crypto_istat_hash - statistics for has algorithm | ||
443 | * @hash_cnt: number of hash requests | ||
444 | * @hash_tlen: total data size hashed | ||
445 | * @hash_err_cnt: number of error for hash requests | ||
446 | */ | ||
447 | struct crypto_istat_hash { | ||
448 | atomic64_t hash_cnt; | ||
449 | atomic64_t hash_tlen; | ||
450 | atomic64_t hash_err_cnt; | ||
451 | }; | ||
452 | |||
453 | /* | ||
454 | * struct crypto_istat_kpp - statistics for KPP algorithm | ||
455 | * @setsecret_cnt: number of setsecrey operation | ||
456 | * @generate_public_key_cnt: number of generate_public_key operation | ||
457 | * @compute_shared_secret_cnt: number of compute_shared_secret operation | ||
458 | * @kpp_err_cnt: number of error for KPP requests | ||
459 | */ | ||
460 | struct crypto_istat_kpp { | ||
461 | atomic64_t setsecret_cnt; | ||
462 | atomic64_t generate_public_key_cnt; | ||
463 | atomic64_t compute_shared_secret_cnt; | ||
464 | atomic64_t kpp_err_cnt; | ||
465 | }; | ||
466 | |||
467 | /* | ||
468 | * struct crypto_istat_rng: statistics for RNG algorithm | ||
469 | * @generate_cnt: number of RNG generate requests | ||
470 | * @generate_tlen: total data size of generated data by the RNG | ||
471 | * @seed_cnt: number of times the RNG was seeded | ||
472 | * @rng_err_cnt: number of error for RNG requests | ||
473 | */ | ||
474 | struct crypto_istat_rng { | ||
475 | atomic64_t generate_cnt; | ||
476 | atomic64_t generate_tlen; | ||
477 | atomic64_t seed_cnt; | ||
478 | atomic64_t rng_err_cnt; | ||
479 | }; | ||
480 | #endif /* CONFIG_CRYPTO_STATS */ | ||
372 | 481 | ||
373 | #define cra_ablkcipher cra_u.ablkcipher | 482 | #define cra_ablkcipher cra_u.ablkcipher |
374 | #define cra_blkcipher cra_u.blkcipher | 483 | #define cra_blkcipher cra_u.blkcipher |
@@ -454,32 +563,7 @@ struct compress_alg { | |||
454 | * @cra_refcnt: internally used | 563 | * @cra_refcnt: internally used |
455 | * @cra_destroy: internally used | 564 | * @cra_destroy: internally used |
456 | * | 565 | * |
457 | * All following statistics are for this crypto_alg | 566 | * @stats: union of all possible crypto_istat_xxx structures |
458 | * @encrypt_cnt: number of encrypt requests | ||
459 | * @decrypt_cnt: number of decrypt requests | ||
460 | * @compress_cnt: number of compress requests | ||
461 | * @decompress_cnt: number of decompress requests | ||
462 | * @generate_cnt: number of RNG generate requests | ||
463 | * @seed_cnt: number of times the rng was seeded | ||
464 | * @hash_cnt: number of hash requests | ||
465 | * @sign_cnt: number of sign requests | ||
466 | * @setsecret_cnt: number of setsecrey operation | ||
467 | * @generate_public_key_cnt: number of generate_public_key operation | ||
468 | * @verify_cnt: number of verify operation | ||
469 | * @compute_shared_secret_cnt: number of compute_shared_secret operation | ||
470 | * @encrypt_tlen: total data size handled by encrypt requests | ||
471 | * @decrypt_tlen: total data size handled by decrypt requests | ||
472 | * @compress_tlen: total data size handled by compress requests | ||
473 | * @decompress_tlen: total data size handled by decompress requests | ||
474 | * @generate_tlen: total data size of generated data by the RNG | ||
475 | * @hash_tlen: total data size hashed | ||
476 | * @akcipher_err_cnt: number of error for akcipher requests | ||
477 | * @cipher_err_cnt: number of error for akcipher requests | ||
478 | * @compress_err_cnt: number of error for akcipher requests | ||
479 | * @aead_err_cnt: number of error for akcipher requests | ||
480 | * @hash_err_cnt: number of error for akcipher requests | ||
481 | * @rng_err_cnt: number of error for akcipher requests | ||
482 | * @kpp_err_cnt: number of error for akcipher requests | ||
483 | * | 567 | * |
484 | * The struct crypto_alg describes a generic Crypto API algorithm and is common | 568 | * The struct crypto_alg describes a generic Crypto API algorithm and is common |
485 | * for all of the transformations. Any variable not documented here shall not | 569 | * for all of the transformations. Any variable not documented here shall not |
@@ -517,42 +601,14 @@ struct crypto_alg { | |||
517 | 601 | ||
518 | #ifdef CONFIG_CRYPTO_STATS | 602 | #ifdef CONFIG_CRYPTO_STATS |
519 | union { | 603 | union { |
520 | atomic64_t encrypt_cnt; | 604 | struct crypto_istat_aead aead; |
521 | atomic64_t compress_cnt; | 605 | struct crypto_istat_akcipher akcipher; |
522 | atomic64_t generate_cnt; | 606 | struct crypto_istat_cipher cipher; |
523 | atomic64_t hash_cnt; | 607 | struct crypto_istat_compress compress; |
524 | atomic64_t setsecret_cnt; | 608 | struct crypto_istat_hash hash; |
525 | }; | 609 | struct crypto_istat_rng rng; |
526 | union { | 610 | struct crypto_istat_kpp kpp; |
527 | atomic64_t encrypt_tlen; | 611 | } stats; |
528 | atomic64_t compress_tlen; | ||
529 | atomic64_t generate_tlen; | ||
530 | atomic64_t hash_tlen; | ||
531 | }; | ||
532 | union { | ||
533 | atomic64_t akcipher_err_cnt; | ||
534 | atomic64_t cipher_err_cnt; | ||
535 | atomic64_t compress_err_cnt; | ||
536 | atomic64_t aead_err_cnt; | ||
537 | atomic64_t hash_err_cnt; | ||
538 | atomic64_t rng_err_cnt; | ||
539 | atomic64_t kpp_err_cnt; | ||
540 | }; | ||
541 | union { | ||
542 | atomic64_t decrypt_cnt; | ||
543 | atomic64_t decompress_cnt; | ||
544 | atomic64_t seed_cnt; | ||
545 | atomic64_t generate_public_key_cnt; | ||
546 | }; | ||
547 | union { | ||
548 | atomic64_t decrypt_tlen; | ||
549 | atomic64_t decompress_tlen; | ||
550 | }; | ||
551 | union { | ||
552 | atomic64_t verify_cnt; | ||
553 | atomic64_t compute_shared_secret_cnt; | ||
554 | }; | ||
555 | atomic64_t sign_cnt; | ||
556 | #endif /* CONFIG_CRYPTO_STATS */ | 612 | #endif /* CONFIG_CRYPTO_STATS */ |
557 | 613 | ||
558 | } CRYPTO_MINALIGN_ATTR; | 614 | } CRYPTO_MINALIGN_ATTR; |