Re: [PATCH v4 04/10] crypto: add quick decompression api

2016-06-02 Thread Herbert Xu
On Tue, May 31, 2016 at 02:55:30PM +0100, Giovanni Cabiddu wrote:
> This patch introduces qdecomp, an asynchronous decompression api.
> qdecomp is a front-end for acomp and scomp algorithms which do not
> not need additional vmalloc work space for decompression.
> 
> Signed-off-by: Giovanni Cabiddu 

I'm sorry to have to make you go through this again but we no
longer have a user for this (I believe they have switched over to
using a per-cpu buffer) so you can now get rid of any code that's
associated with qdecomp.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 04/10] crypto: add quick decompression api

2016-05-31 Thread Giovanni Cabiddu
This patch introduces qdecomp, an asynchronous decompression api.
qdecomp is a front-end for acomp and scomp algorithms which do not
not need additional vmalloc work space for decompression.

Signed-off-by: Giovanni Cabiddu 
---
 crypto/Makefile   |1 +
 crypto/acompress.c|   50 -
 crypto/qdecompress.c  |   93 +++
 crypto/scompress.c|   92 +++-
 include/crypto/internal/acompress.h   |   15 +++
 include/crypto/internal/qdecompress.h |   22 
 include/crypto/internal/scompress.h   |   14 +++
 include/crypto/qdecompress.h  |  204 +
 include/linux/crypto.h|4 +
 9 files changed, 491 insertions(+), 4 deletions(-)
 create mode 100644 crypto/qdecompress.c
 create mode 100644 include/crypto/internal/qdecompress.h
 create mode 100644 include/crypto/qdecompress.h

diff --git a/crypto/Makefile b/crypto/Makefile
index fc8fcfe..2621451 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 
 obj-$(CONFIG_CRYPTO_ACOMP2) += acompress.o
 obj-$(CONFIG_CRYPTO_ACOMP2) += scompress.o
+obj-$(CONFIG_CRYPTO_ACOMP2) += qdecompress.o
 
 $(obj)/rsapubkey-asn1.o: $(obj)/rsapubkey-asn1.c $(obj)/rsapubkey-asn1.h
 $(obj)/rsaprivkey-asn1.o: $(obj)/rsaprivkey-asn1.c $(obj)/rsaprivkey-asn1.h
diff --git a/crypto/acompress.c b/crypto/acompress.c
index 885d15d..dcc9ddc 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -23,9 +23,10 @@
 #include 
 #include 
 #include 
+#include 
 #include "internal.h"
 
-static const struct crypto_type crypto_acomp_type;
+const struct crypto_type crypto_acomp_type;
 
 #ifdef CONFIG_NET
 static int crypto_acomp_report(struct sk_buff *skb, struct crypto_alg *alg)
@@ -96,7 +97,39 @@ unsigned int crypto_acomp_extsize(struct crypto_alg *alg)
return extsize;
 }
 
-static const struct crypto_type crypto_acomp_type = {
+static void crypto_exit_acomp_ops_nospace(struct crypto_tfm *tfm)
+{
+   struct crypto_tfm **ctx = crypto_tfm_ctx(tfm);
+   struct crypto_acomp *acomp = __crypto_acomp_tfm(*ctx);
+
+   crypto_free_acomp(acomp);
+   *ctx = NULL;
+}
+
+int crypto_init_acomp_ops_nospace(struct crypto_tfm *tfm)
+{
+   struct crypto_alg *calg = tfm->__crt_alg;
+   struct crypto_qdecomp *crt = __crypto_qdecomp_tfm(tfm);
+   struct crypto_tfm **ctx = crypto_tfm_ctx(tfm);
+   struct crypto_acomp *acomp;
+
+   if (!crypto_mod_get(calg))
+   return -EAGAIN;
+
+   acomp = crypto_create_tfm(calg, _acomp_type);
+   if (IS_ERR(acomp)) {
+   crypto_mod_put(calg);
+   return PTR_ERR(acomp);
+   }
+
+   *ctx = >base;
+   tfm->exit = crypto_exit_acomp_ops_nospace;
+   crt->decompress = (int (*)(struct qdecomp_req *req))acomp->decompress;
+
+   return 0;
+}
+
+const struct crypto_type crypto_acomp_type = {
.extsize = crypto_acomp_extsize,
.init_tfm = crypto_acomp_init_tfm,
 #ifdef CONFIG_PROC_FS
@@ -108,6 +141,7 @@ static const struct crypto_type crypto_acomp_type = {
.type = CRYPTO_ALG_TYPE_ACOMPRESS,
.tfmsize = offsetof(struct crypto_acomp, base),
 };
+EXPORT_SYMBOL_GPL(crypto_acomp_type);
 
 struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
u32 mask)
@@ -153,6 +187,18 @@ int crypto_register_acomp(struct acomp_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_register_acomp);
 
+int crypto_register_acomp_qdecomp(struct acomp_alg *alg)
+{
+   struct crypto_alg *base = >base;
+
+   base->cra_type = _acomp_type;
+   base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
+   base->cra_flags |= CRYPTO_ALG_TYPE_ACOMPRESS_QDCMP;
+
+   return crypto_register_alg(base);
+}
+EXPORT_SYMBOL_GPL(crypto_register_acomp_qdecomp);
+
 int crypto_unregister_acomp(struct acomp_alg *alg)
 {
return crypto_unregister_alg(>base);
diff --git a/crypto/qdecompress.c b/crypto/qdecompress.c
new file mode 100644
index 000..f229016
--- /dev/null
+++ b/crypto/qdecompress.c
@@ -0,0 +1,93 @@
+/*
+ * Quick Decompression operations
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * Authors: Giovanni Cabiddu 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "internal.h"
+
+#ifdef CONFIG_NET
+static int crypto_qdecomp_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+   struct crypto_report_comp rqdecomp;
+
+   strncpy(rqdecomp.type, "qdecomp", sizeof(rqdecomp.type));
+
+   if (nla_put(skb,