summaryrefslogtreecommitdiff
path: root/drivers/crypto/nx/nx-842.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-05-07 20:49:18 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2015-05-11 10:06:46 +0300
commit959e6659b6f74ec1fa4d391a3b88d63dc0189f36 (patch)
tree13e716f492a528a093e061fec08e7ed74dbaddcc /drivers/crypto/nx/nx-842.c
parent7011a122383e36dab594406720fa1d089e0be8f9 (diff)
downloadlinux-959e6659b6f74ec1fa4d391a3b88d63dc0189f36.tar.xz
crypto: nx - add nx842 constraints
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/nx/nx-842.c')
-rw-r--r--drivers/crypto/nx/nx-842.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c
index f1f378eef373..160fe2d97336 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)