Commit 6a8dbd71 authored by Herbert Xu's avatar Herbert Xu
Browse files

Revert "crypto: remove CONFIG_CRYPTO_STATS"



This reverts commit 2beb81fb.

While removing CONFIG_CRYPTO_STATS is a worthy goal, this also
removed unrelated infrastructure such as crypto_comp_alg_common.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 77292bb8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -766,6 +766,7 @@ CONFIG_CRYPTO_USER_API_HASH=m
CONFIG_CRYPTO_USER_API_SKCIPHER=m
CONFIG_CRYPTO_USER_API_RNG=m
CONFIG_CRYPTO_USER_API_AEAD=m
CONFIG_CRYPTO_STATS=y
CONFIG_CRYPTO_CRC32_S390=y
CONFIG_CRYPTO_SHA512_S390=m
CONFIG_CRYPTO_SHA1_S390=m
+1 −0
Original line number Diff line number Diff line
@@ -752,6 +752,7 @@ CONFIG_CRYPTO_USER_API_HASH=m
CONFIG_CRYPTO_USER_API_SKCIPHER=m
CONFIG_CRYPTO_USER_API_RNG=m
CONFIG_CRYPTO_USER_API_AEAD=m
CONFIG_CRYPTO_STATS=y
CONFIG_CRYPTO_CRC32_S390=y
CONFIG_CRYPTO_SHA512_S390=m
CONFIG_CRYPTO_SHA1_S390=m
+20 −0
Original line number Diff line number Diff line
@@ -1456,6 +1456,26 @@ config CRYPTO_USER_API_ENABLE_OBSOLETE
	  already been phased out from internal use by the kernel, and are
	  only useful for userspace clients that still rely on them.

config CRYPTO_STATS
	bool "Crypto usage statistics"
	depends on CRYPTO_USER
	help
	  Enable the gathering of crypto stats.

	  Enabling this option reduces the performance of the crypto API.  It
	  should only be enabled when there is actually a use case for it.

	  This collects data sizes, numbers of requests, and numbers
	  of errors processed by:
	  - AEAD ciphers (encrypt, decrypt)
	  - asymmetric key ciphers (encrypt, decrypt, verify, sign)
	  - symmetric key ciphers (encrypt, decrypt)
	  - compression algorithms (compress, decompress)
	  - hash algorithms (hash)
	  - key-agreement protocol primitives (setsecret, generate
	    public key, compute shared secret)
	  - RNG (generate, seed)

endmenu

config CRYPTO_HASH_INFO
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ cryptomgr-y := algboss.o testmgr.o

obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
crypto_user-y := crypto_user_base.o
crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
+44 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ static const struct crypto_type crypto_acomp_type;

static inline struct acomp_alg *__crypto_acomp_alg(struct crypto_alg *alg)
{
	return container_of(alg, struct acomp_alg, base);
	return container_of(alg, struct acomp_alg, calg.base);
}

static inline struct acomp_alg *crypto_acomp_alg(struct crypto_acomp *tfm)
@@ -93,6 +93,32 @@ static unsigned int crypto_acomp_extsize(struct crypto_alg *alg)
	return extsize;
}

static inline int __crypto_acomp_report_stat(struct sk_buff *skb,
					     struct crypto_alg *alg)
{
	struct comp_alg_common *calg = __crypto_comp_alg_common(alg);
	struct crypto_istat_compress *istat = comp_get_stat(calg);
	struct crypto_stat_compress racomp;

	memset(&racomp, 0, sizeof(racomp));

	strscpy(racomp.type, "acomp", sizeof(racomp.type));
	racomp.stat_compress_cnt = atomic64_read(&istat->compress_cnt);
	racomp.stat_compress_tlen = atomic64_read(&istat->compress_tlen);
	racomp.stat_decompress_cnt =  atomic64_read(&istat->decompress_cnt);
	racomp.stat_decompress_tlen = atomic64_read(&istat->decompress_tlen);
	racomp.stat_err_cnt = atomic64_read(&istat->err_cnt);

	return nla_put(skb, CRYPTOCFGA_STAT_ACOMP, sizeof(racomp), &racomp);
}

#ifdef CONFIG_CRYPTO_STATS
int crypto_acomp_report_stat(struct sk_buff *skb, struct crypto_alg *alg)
{
	return __crypto_acomp_report_stat(skb, alg);
}
#endif

static const struct crypto_type crypto_acomp_type = {
	.extsize = crypto_acomp_extsize,
	.init_tfm = crypto_acomp_init_tfm,
@@ -101,6 +127,9 @@ static const struct crypto_type crypto_acomp_type = {
#endif
#if IS_ENABLED(CONFIG_CRYPTO_USER)
	.report = crypto_acomp_report,
#endif
#ifdef CONFIG_CRYPTO_STATS
	.report_stat = crypto_acomp_report_stat,
#endif
	.maskclear = ~CRYPTO_ALG_TYPE_MASK,
	.maskset = CRYPTO_ALG_TYPE_ACOMPRESS_MASK,
@@ -153,12 +182,24 @@ void acomp_request_free(struct acomp_req *req)
}
EXPORT_SYMBOL_GPL(acomp_request_free);

int crypto_register_acomp(struct acomp_alg *alg)
void comp_prepare_alg(struct comp_alg_common *alg)
{
	struct crypto_istat_compress *istat = comp_get_stat(alg);
	struct crypto_alg *base = &alg->base;

	base->cra_type = &crypto_acomp_type;
	base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;

	if (IS_ENABLED(CONFIG_CRYPTO_STATS))
		memset(istat, 0, sizeof(*istat));
}

int crypto_register_acomp(struct acomp_alg *alg)
{
	struct crypto_alg *base = &alg->calg.base;

	comp_prepare_alg(&alg->calg);

	base->cra_type = &crypto_acomp_type;
	base->cra_flags |= CRYPTO_ALG_TYPE_ACOMPRESS;

	return crypto_register_alg(base);
Loading