linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Streetman <ddstreet@ieee.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Cc: Seth Jennings <sjennings@variantweb.net>,
	Robert Jennings <rob@pochix.net>,
	linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, Dan Streetman <ddstreet@ieee.org>
Subject: [PATCH 07/10] drivers/crypto/nx: add nx842 constraints
Date: Thu,  7 May 2015 13:49:18 -0400	[thread overview]
Message-ID: <1431020961-22285-8-git-send-email-ddstreet@ieee.org> (raw)
In-Reply-To: <1431020961-22285-1-git-send-email-ddstreet@ieee.org>

Add "constraints" for the NX-842 driver.  The constraints are used to
indicate what the current NX-842 platform driver is capable of.  The
constraints tell the NX-842 user what alignment, min and max length, and
length multiple each provided buffers should conform to.  These are
required because the 842 hardware requires buffers to meet specific
constraints that vary based on platform - for example, the pSeries
max length is much lower than the PowerNV max length.

Signed-off-by: Dan Streetman <ddstreet@ieee.org>
---
 drivers/crypto/nx/nx-842-pseries.c | 10 ++++++++++
 drivers/crypto/nx/nx-842.c         | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/crypto/nx/nx-842.h         |  2 ++
 include/linux/nx842.h              |  9 +++++++++
 4 files changed, 59 insertions(+)

diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
index 9b83c9e..cb481d8 100644
--- a/drivers/crypto/nx/nx-842-pseries.c
+++ b/drivers/crypto/nx/nx-842-pseries.c
@@ -40,6 +40,13 @@ MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors");
 /* IO buffer must be 128 byte aligned */
 #define IO_BUFFER_ALIGN 128
 
+static struct nx842_constraints nx842_pseries_constraints = {
+	.alignment =	IO_BUFFER_ALIGN,
+	.multiple =	DDE_BUFFER_LAST_MULT,
+	.minimum =	IO_BUFFER_ALIGN,
+	.maximum =	PAGE_SIZE, /* dynamic, max_sync_size */
+};
+
 struct nx842_header {
 	int blocks_nr; /* number of compressed blocks */
 	int offset; /* offset of the first block (from beginning of header) */
@@ -842,6 +849,8 @@ static int nx842_OF_upd_maxsyncop(struct nx842_devdata *devdata,
 		goto out;
 	}
 
+	nx842_pseries_constraints.maximum = devdata->max_sync_size;
+
 	devdata->max_sync_sg = (unsigned int)min(maxsynccop->comp_sg_limit,
 						maxsynccop->decomp_sg_limit);
 	if (devdata->max_sync_sg < 1) {
@@ -1115,6 +1124,7 @@ static struct attribute_group nx842_attribute_group = {
 
 static struct nx842_driver nx842_pseries_driver = {
 	.owner =	THIS_MODULE,
+	.constraints =	&nx842_pseries_constraints,
 	.compress =	nx842_pseries_compress,
 	.decompress =	nx842_pseries_decompress,
 };
diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c
index f1f378e..160fe2d 100644
--- a/drivers/crypto/nx/nx-842.c
+++ b/drivers/crypto/nx/nx-842.c
@@ -86,6 +86,44 @@ static void put_driver(struct nx842_driver *driver)
 	module_put(driver->owner);
 }
 
+/**
+ * nx842_constraints
+ *
+ * This provides the driver's constraints.  Different nx842 implementations
+ * may have varying requirements.  The constraints are:
+ *   @alignment:	All buffers should be aligned to this
+ *   @multiple:		All buffer lengths should be a multiple of this
+ *   @minimum:		Buffer lengths must not be less than this amount
+ *   @maximum:		Buffer lengths must not be more than this amount
+ *
+ * The constraints apply to all buffers and lengths, both input and output,
+ * for both compression and decompression, except for the minimum which
+ * only applies to compression input and decompression output; the
+ * compressed data can be less than the minimum constraint.  It can be
+ * assumed that compressed data will always adhere to the multiple
+ * constraint.
+ *
+ * The driver may succeed even if these constraints are violated;
+ * however the driver can return failure or suffer reduced performance
+ * if any constraint is not met.
+ */
+int nx842_constraints(struct nx842_constraints *c)
+{
+	struct nx842_driver *driver = get_driver();
+	int ret = 0;
+
+	if (!driver)
+		return -ENODEV;
+
+	BUG_ON(!c);
+	memcpy(c, driver->constraints, sizeof(*c));
+
+	put_driver(driver);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nx842_constraints);
+
 int nx842_compress(const unsigned char *in, unsigned int in_len,
 		   unsigned char *out, unsigned int *out_len,
 		   void *wrkmem)
diff --git a/drivers/crypto/nx/nx-842.h b/drivers/crypto/nx/nx-842.h
index 2a5d4e1..c6ceb0f 100644
--- a/drivers/crypto/nx/nx-842.h
+++ b/drivers/crypto/nx/nx-842.h
@@ -12,6 +12,8 @@
 struct nx842_driver {
 	struct module *owner;
 
+	struct nx842_constraints *constraints;
+
 	int (*compress)(const unsigned char *in, unsigned int in_len,
 			unsigned char *out, unsigned int *out_len,
 			void *wrkmem);
diff --git a/include/linux/nx842.h b/include/linux/nx842.h
index d919c22..aa1a97e9 100644
--- a/include/linux/nx842.h
+++ b/include/linux/nx842.h
@@ -5,6 +5,15 @@
 
 #define NX842_MEM_COMPRESS	__NX842_PSERIES_MEM_COMPRESS
 
+struct nx842_constraints {
+	int alignment;
+	int multiple;
+	int minimum;
+	int maximum;
+};
+
+int nx842_constraints(struct nx842_constraints *constraints);
+
 int nx842_compress(const unsigned char *in, unsigned int in_len,
 		   unsigned char *out, unsigned int *out_len, void *wrkmem);
 int nx842_decompress(const unsigned char *in, unsigned int in_len,
-- 
2.1.0


  parent reply	other threads:[~2015-05-07 17:50 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 17:34 [PATCH 00/11] add 842 hw compression for PowerNV platform Dan Streetman
2015-04-07 17:34 ` [PATCH 01/11] powerpc: export of_get_ibm_chip_id function Dan Streetman
2015-04-07 17:34 ` [PATCH 02/11] powerpc: Add ICSWX instruction Dan Streetman
2015-04-07 17:34 ` [PATCH 03/11] crypto: add software 842 decompression Dan Streetman
2015-04-07 17:34 ` [PATCH 04/11] drivers/crypto/nx: move nx-842.c to nx-842-pseries.c Dan Streetman
2015-04-07 17:34 ` [PATCH 05/11] drivers/crypto/nx: add NX-842 platform frontend driver Dan Streetman
2015-04-07 17:34 ` [PATCH 06/11] drivers/crypto/nx: add nx842 constraints Dan Streetman
2015-04-07 17:34 ` [PATCH 07/11] drivers/crypto/nx: add PowerNV platform NX-842 driver Dan Streetman
2015-04-07 17:34 ` [PATCH 08/11] drivers/crypto/nx: simplify pSeries nx842 driver Dan Streetman
2015-04-07 17:34 ` [PATCH 09/11] crypto: remove LZO fallback from crypto 842 Dan Streetman
2015-04-08 14:16   ` Herbert Xu
2015-04-08 14:28     ` Dan Streetman
2015-04-08 14:38       ` Herbert Xu
2015-04-08 14:45         ` Dan Streetman
2015-04-08 14:48           ` Herbert Xu
2015-04-07 17:34 ` [PATCH 10/11] crypto: rewrite crypto 842 to use nx842 constraints Dan Streetman
2015-04-07 17:34 ` [PATCH 11/11] crypto: add crypto compression sefltest Dan Streetman
2015-04-08 14:16   ` Herbert Xu
2015-04-08 14:48     ` Dan Streetman
2015-05-06 16:50 ` [PATCHv2 00/10] add 842 hw compression for PowerNV platform Dan Streetman
2015-05-06 16:50   ` [PATCH 01/10] powerpc: export of_get_ibm_chip_id function Dan Streetman
2015-05-06 16:50   ` [PATCH 02/10] powerpc: Add ICSWX instruction Dan Streetman
2015-05-06 16:50   ` [PATCH 03/10] lib: add software 842 compression/decompression Dan Streetman
2015-05-06 16:51   ` [PATCH 04/10] crypto: change 842 alg to use software Dan Streetman
2015-05-07  3:07     ` Herbert Xu
2015-05-06 16:51   ` [PATCH 05/10] drivers/crypto/nx: rename nx-842.c to nx-842-pseries.c Dan Streetman
2015-05-06 16:51   ` [PATCH 06/10] drivers/crypto/nx: add NX-842 platform frontend driver Dan Streetman
2015-05-06 16:51   ` [PATCH 07/10] drivers/crypto/nx: add nx842 constraints Dan Streetman
2015-05-06 16:51   ` [PATCH 08/10] drivers/crypto/nx: add PowerNV platform NX-842 driver Dan Streetman
2015-05-06 16:51   ` [PATCH 09/10] drivers/crypto/nx: simplify pSeries nx842 driver Dan Streetman
2015-05-06 16:51   ` [PATCH 10/10] drivers/crypto/nx: add hardware 842 crypto comp alg Dan Streetman
2015-05-07  3:12     ` Herbert Xu
2015-05-07 15:06       ` Dan Streetman
2015-05-08  2:32         ` Herbert Xu
2015-05-07 17:49   ` [PATCHv3 00/10] add 842 hw compression for PowerNV platform Dan Streetman
2015-05-07 17:49     ` [PATCH 01/10] powerpc: export of_get_ibm_chip_id function Dan Streetman
2015-05-07 17:49     ` [PATCH 02/10] powerpc: Add ICSWX instruction Dan Streetman
2015-05-07 17:49     ` [PATCH 03/10] lib: add software 842 compression/decompression Dan Streetman
2015-05-07 17:49     ` [PATCH 04/10] crypto: change 842 alg to use software Dan Streetman
2015-05-07 17:49     ` [PATCH 05/10] drivers/crypto/nx: rename nx-842.c to nx-842-pseries.c Dan Streetman
2015-05-07 17:49     ` [PATCH 06/10] drivers/crypto/nx: add NX-842 platform frontend driver Dan Streetman
2015-05-07 17:49     ` Dan Streetman [this message]
2015-05-07 17:49     ` [PATCH 08/10] drivers/crypto/nx: add PowerNV platform NX-842 driver Dan Streetman
2015-05-07 17:49     ` [PATCH 09/10] drivers/crypto/nx: simplify pSeries nx842 driver Dan Streetman
2015-05-07 17:49     ` [PATCH 10/10] drivers/crypto/nx: add hardware 842 crypto comp alg Dan Streetman
2015-05-11  7:21     ` [PATCHv3 00/10] add 842 hw compression for PowerNV platform Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431020961-22285-8-git-send-email-ddstreet@ieee.org \
    --to=ddstreet@ieee.org \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=rob@pochix.net \
    --cc=sjennings@variantweb.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).