[PATCH 2/3] crypto: Add inline per-cpu wrappers for compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds wrapper functions for compression users
that allocate and free per-cpu compression transforms

Signed-off-by: Seth Jennings <sjenning@xxxxxxxxxxxxxxxxxx>
---
 include/linux/crypto.h |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 8a94217..5ed19c1 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -483,6 +483,10 @@ struct crypto_attr_u32 {
  
 struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
 void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
+struct crypto_tfm * __percpu *crypto_alloc_percpu_tfms(const char *alg_name,
+			u32 type, u32 mask, const struct cpumask *cpumask);
+void crypto_free_percpu_tfms(struct crypto_tfm * __percpu *tfms,
+				const struct cpumask *cpumask);
 
 static inline void crypto_free_tfm(struct crypto_tfm *tfm)
 {
@@ -1213,6 +1217,12 @@ static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
 	return (struct crypto_comp *)tfm;
 }
 
+static inline struct crypto_comp * __percpu *__crypto_comp_percpu_cast(
+	struct crypto_tfm * __percpu *tfms)
+{
+	return (struct crypto_comp * __percpu *)tfms;
+}
+
 static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm)
 {
 	BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) &
@@ -1230,6 +1240,17 @@ static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
 	return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));
 }
 
+static inline struct crypto_comp * __percpu *crypto_alloc_percpu_comp(
+	const char *alg_name, u32 type, u32 mask, const struct cpumask *cpumask)
+{
+	type &= ~CRYPTO_ALG_TYPE_MASK;
+	type |= CRYPTO_ALG_TYPE_COMPRESS;
+	mask |= CRYPTO_ALG_TYPE_MASK;
+
+	return __crypto_comp_percpu_cast(crypto_alloc_percpu_tfms(alg_name,
+							type, mask, cpumask));
+}
+
 static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
 {
 	return &tfm->base;
@@ -1240,6 +1261,13 @@ static inline void crypto_free_comp(struct crypto_comp *tfm)
 	crypto_free_tfm(crypto_comp_tfm(tfm));
 }
 
+static inline void crypto_free_percpu_comp(struct crypto_comp * __percpu *tfms,
+				const struct cpumask *cpumask)
+{
+	crypto_free_percpu_tfms((struct crypto_tfm * __percpu *)(tfms),
+		cpumask);
+}
+
 static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
 {
 	type &= ~CRYPTO_ALG_TYPE_MASK;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux