diff options
author | Dan Streetman <ddstreet@ieee.org> | 2015-05-07 13:49:17 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-11 03:06:46 -0400 |
commit | 7011a122383e36dab594406720fa1d089e0be8f9 (patch) | |
tree | cd69055e54a29a9628331d8594545e50878352f3 /drivers/crypto/nx/nx-842-pseries.c | |
parent | fdd05e4b9ae22603ed09beb4e179ae7746555a81 (diff) |
crypto: nx - add NX-842 platform frontend driver
Add NX-842 frontend that allows using either the pSeries platform or
PowerNV platform driver (to be added by later patch) for the NX-842
hardware. Update the MAINTAINERS file to include the new filenames.
Update Kconfig files to clarify titles and descriptions, and correct
dependencies.
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-pseries.c')
-rw-r--r-- | drivers/crypto/nx/nx-842-pseries.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c index 887196e9b50c..9b83c9e7fd73 100644 --- a/drivers/crypto/nx/nx-842-pseries.c +++ b/drivers/crypto/nx/nx-842-pseries.c | |||
@@ -21,18 +21,13 @@ | |||
21 | * Seth Jennings <sjenning@linux.vnet.ibm.com> | 21 | * Seth Jennings <sjenning@linux.vnet.ibm.com> |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/nx842.h> | ||
27 | #include <linux/of.h> | ||
28 | #include <linux/slab.h> | ||
29 | |||
30 | #include <asm/page.h> | 24 | #include <asm/page.h> |
31 | #include <asm/vio.h> | 25 | #include <asm/vio.h> |
32 | 26 | ||
27 | #include "nx-842.h" | ||
33 | #include "nx_csbcpb.h" /* struct nx_csbcpb */ | 28 | #include "nx_csbcpb.h" /* struct nx_csbcpb */ |
34 | 29 | ||
35 | #define MODULE_NAME "nx-compress" | 30 | #define MODULE_NAME NX842_PSERIES_MODULE_NAME |
36 | MODULE_LICENSE("GPL"); | 31 | MODULE_LICENSE("GPL"); |
37 | MODULE_AUTHOR("Robert Jennings <rcj@linux.vnet.ibm.com>"); | 32 | MODULE_AUTHOR("Robert Jennings <rcj@linux.vnet.ibm.com>"); |
38 | MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); | 33 | MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); |
@@ -236,18 +231,6 @@ struct nx842_workmem { | |||
236 | }; | 231 | }; |
237 | }; | 232 | }; |
238 | 233 | ||
239 | int nx842_get_workmem_size(void) | ||
240 | { | ||
241 | return sizeof(struct nx842_workmem) + NX842_HW_PAGE_SIZE; | ||
242 | } | ||
243 | EXPORT_SYMBOL_GPL(nx842_get_workmem_size); | ||
244 | |||
245 | int nx842_get_workmem_size_aligned(void) | ||
246 | { | ||
247 | return sizeof(struct nx842_workmem); | ||
248 | } | ||
249 | EXPORT_SYMBOL_GPL(nx842_get_workmem_size_aligned); | ||
250 | |||
251 | static int nx842_validate_result(struct device *dev, | 234 | static int nx842_validate_result(struct device *dev, |
252 | struct cop_status_block *csb) | 235 | struct cop_status_block *csb) |
253 | { | 236 | { |
@@ -300,7 +283,7 @@ static int nx842_validate_result(struct device *dev, | |||
300 | } | 283 | } |
301 | 284 | ||
302 | /** | 285 | /** |
303 | * nx842_compress - Compress data using the 842 algorithm | 286 | * nx842_pseries_compress - Compress data using the 842 algorithm |
304 | * | 287 | * |
305 | * Compression provide by the NX842 coprocessor on IBM Power systems. | 288 | * Compression provide by the NX842 coprocessor on IBM Power systems. |
306 | * The input buffer is compressed and the result is stored in the | 289 | * The input buffer is compressed and the result is stored in the |
@@ -315,7 +298,7 @@ static int nx842_validate_result(struct device *dev, | |||
315 | * @out: Pointer to output buffer | 298 | * @out: Pointer to output buffer |
316 | * @outlen: Length of output buffer | 299 | * @outlen: Length of output buffer |
317 | * @wrkmem: ptr to buffer for working memory, size determined by | 300 | * @wrkmem: ptr to buffer for working memory, size determined by |
318 | * nx842_get_workmem_size() | 301 | * NX842_MEM_COMPRESS |
319 | * | 302 | * |
320 | * Returns: | 303 | * Returns: |
321 | * 0 Success, output of length @outlen stored in the buffer at @out | 304 | * 0 Success, output of length @outlen stored in the buffer at @out |
@@ -325,8 +308,9 @@ static int nx842_validate_result(struct device *dev, | |||
325 | * -EIO Internal error | 308 | * -EIO Internal error |
326 | * -ENODEV Hardware unavailable | 309 | * -ENODEV Hardware unavailable |
327 | */ | 310 | */ |
328 | int nx842_compress(const unsigned char *in, unsigned int inlen, | 311 | static int nx842_pseries_compress(const unsigned char *in, unsigned int inlen, |
329 | unsigned char *out, unsigned int *outlen, void *wmem) | 312 | unsigned char *out, unsigned int *outlen, |
313 | void *wmem) | ||
330 | { | 314 | { |
331 | struct nx842_header *hdr; | 315 | struct nx842_header *hdr; |
332 | struct nx842_devdata *local_devdata; | 316 | struct nx842_devdata *local_devdata; |
@@ -493,13 +477,12 @@ unlock: | |||
493 | rcu_read_unlock(); | 477 | rcu_read_unlock(); |
494 | return ret; | 478 | return ret; |
495 | } | 479 | } |
496 | EXPORT_SYMBOL_GPL(nx842_compress); | ||
497 | 480 | ||
498 | static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, | 481 | static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, |
499 | const void *); | 482 | const void *); |
500 | 483 | ||
501 | /** | 484 | /** |
502 | * nx842_decompress - Decompress data using the 842 algorithm | 485 | * nx842_pseries_decompress - Decompress data using the 842 algorithm |
503 | * | 486 | * |
504 | * Decompression provide by the NX842 coprocessor on IBM Power systems. | 487 | * Decompression provide by the NX842 coprocessor on IBM Power systems. |
505 | * The input buffer is decompressed and the result is stored in the | 488 | * The input buffer is decompressed and the result is stored in the |
@@ -515,7 +498,7 @@ static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, | |||
515 | * @out: Pointer to output buffer, must be page aligned | 498 | * @out: Pointer to output buffer, must be page aligned |
516 | * @outlen: Length of output buffer, must be PAGE_SIZE | 499 | * @outlen: Length of output buffer, must be PAGE_SIZE |
517 | * @wrkmem: ptr to buffer for working memory, size determined by | 500 | * @wrkmem: ptr to buffer for working memory, size determined by |
518 | * nx842_get_workmem_size() | 501 | * NX842_MEM_COMPRESS |
519 | * | 502 | * |
520 | * Returns: | 503 | * Returns: |
521 | * 0 Success, output of length @outlen stored in the buffer at @out | 504 | * 0 Success, output of length @outlen stored in the buffer at @out |
@@ -525,8 +508,9 @@ static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, | |||
525 | * -EINVAL Bad input data encountered when attempting decompress | 508 | * -EINVAL Bad input data encountered when attempting decompress |
526 | * -EIO Internal error | 509 | * -EIO Internal error |
527 | */ | 510 | */ |
528 | int nx842_decompress(const unsigned char *in, unsigned int inlen, | 511 | static int nx842_pseries_decompress(const unsigned char *in, unsigned int inlen, |
529 | unsigned char *out, unsigned int *outlen, void *wmem) | 512 | unsigned char *out, unsigned int *outlen, |
513 | void *wmem) | ||
530 | { | 514 | { |
531 | struct nx842_header *hdr; | 515 | struct nx842_header *hdr; |
532 | struct nx842_devdata *local_devdata; | 516 | struct nx842_devdata *local_devdata; |
@@ -694,7 +678,6 @@ unlock: | |||
694 | rcu_read_unlock(); | 678 | rcu_read_unlock(); |
695 | return ret; | 679 | return ret; |
696 | } | 680 | } |
697 | EXPORT_SYMBOL_GPL(nx842_decompress); | ||
698 | 681 | ||
699 | /** | 682 | /** |
700 | * nx842_OF_set_defaults -- Set default (disabled) values for devdata | 683 | * nx842_OF_set_defaults -- Set default (disabled) values for devdata |
@@ -1130,6 +1113,12 @@ static struct attribute_group nx842_attribute_group = { | |||
1130 | .attrs = nx842_sysfs_entries, | 1113 | .attrs = nx842_sysfs_entries, |
1131 | }; | 1114 | }; |
1132 | 1115 | ||
1116 | static struct nx842_driver nx842_pseries_driver = { | ||
1117 | .owner = THIS_MODULE, | ||
1118 | .compress = nx842_pseries_compress, | ||
1119 | .decompress = nx842_pseries_decompress, | ||
1120 | }; | ||
1121 | |||
1133 | static int __init nx842_probe(struct vio_dev *viodev, | 1122 | static int __init nx842_probe(struct vio_dev *viodev, |
1134 | const struct vio_device_id *id) | 1123 | const struct vio_device_id *id) |
1135 | { | 1124 | { |
@@ -1192,6 +1181,8 @@ static int __init nx842_probe(struct vio_dev *viodev, | |||
1192 | goto error; | 1181 | goto error; |
1193 | } | 1182 | } |
1194 | 1183 | ||
1184 | nx842_register_driver(&nx842_pseries_driver); | ||
1185 | |||
1195 | return 0; | 1186 | return 0; |
1196 | 1187 | ||
1197 | error_unlock: | 1188 | error_unlock: |
@@ -1222,11 +1213,14 @@ static int __exit nx842_remove(struct vio_dev *viodev) | |||
1222 | if (old_devdata) | 1213 | if (old_devdata) |
1223 | kfree(old_devdata->counters); | 1214 | kfree(old_devdata->counters); |
1224 | kfree(old_devdata); | 1215 | kfree(old_devdata); |
1216 | |||
1217 | nx842_unregister_driver(&nx842_pseries_driver); | ||
1218 | |||
1225 | return 0; | 1219 | return 0; |
1226 | } | 1220 | } |
1227 | 1221 | ||
1228 | static struct vio_device_id nx842_driver_ids[] = { | 1222 | static struct vio_device_id nx842_driver_ids[] = { |
1229 | {"ibm,compression-v1", "ibm,compression"}, | 1223 | {NX842_PSERIES_COMPAT_NAME "-v1", NX842_PSERIES_COMPAT_NAME}, |
1230 | {"", ""}, | 1224 | {"", ""}, |
1231 | }; | 1225 | }; |
1232 | 1226 | ||
@@ -1243,6 +1237,8 @@ static int __init nx842_init(void) | |||
1243 | struct nx842_devdata *new_devdata; | 1237 | struct nx842_devdata *new_devdata; |
1244 | pr_info("Registering IBM Power 842 compression driver\n"); | 1238 | pr_info("Registering IBM Power 842 compression driver\n"); |
1245 | 1239 | ||
1240 | BUILD_BUG_ON(sizeof(struct nx842_workmem) > NX842_MEM_COMPRESS); | ||
1241 | |||
1246 | RCU_INIT_POINTER(devdata, NULL); | 1242 | RCU_INIT_POINTER(devdata, NULL); |
1247 | new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL); | 1243 | new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL); |
1248 | if (!new_devdata) { | 1244 | if (!new_devdata) { |
@@ -1272,6 +1268,7 @@ static void __exit nx842_exit(void) | |||
1272 | if (old_devdata) | 1268 | if (old_devdata) |
1273 | dev_set_drvdata(old_devdata->dev, NULL); | 1269 | dev_set_drvdata(old_devdata->dev, NULL); |
1274 | kfree(old_devdata); | 1270 | kfree(old_devdata); |
1271 | nx842_unregister_driver(&nx842_pseries_driver); | ||
1275 | vio_unregister_driver(&nx842_driver); | 1272 | vio_unregister_driver(&nx842_driver); |
1276 | } | 1273 | } |
1277 | 1274 | ||