diff options
-rw-r--r-- | MAINTAINERS | 2 | ||||
-rw-r--r-- | drivers/crypto/Kconfig | 10 | ||||
-rw-r--r-- | drivers/crypto/nx/Kconfig | 35 | ||||
-rw-r--r-- | drivers/crypto/nx/Makefile | 4 | ||||
-rw-r--r-- | drivers/crypto/nx/nx-842-pseries.c | 57 | ||||
-rw-r--r-- | drivers/crypto/nx/nx-842.c | 144 | ||||
-rw-r--r-- | drivers/crypto/nx/nx-842.h | 32 | ||||
-rw-r--r-- | include/linux/nx842.h | 10 |
8 files changed, 245 insertions, 49 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index a13b4b10ff46..912c9d9f741c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -4861,7 +4861,7 @@ F: drivers/crypto/nx/ | |||
4861 | IBM Power 842 compression accelerator | 4861 | IBM Power 842 compression accelerator |
4862 | M: Dan Streetman <ddstreet@us.ibm.com> | 4862 | M: Dan Streetman <ddstreet@us.ibm.com> |
4863 | S: Supported | 4863 | S: Supported |
4864 | F: drivers/crypto/nx/nx-842.c | 4864 | F: drivers/crypto/nx/nx-842* |
4865 | F: include/linux/nx842.h | 4865 | F: include/linux/nx842.h |
4866 | F: include/linux/sw842.h | 4866 | F: include/linux/sw842.h |
4867 | F: crypto/842.c | 4867 | F: crypto/842.c |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 8a76a012be61..0889e496d886 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
@@ -330,11 +330,13 @@ config CRYPTO_DEV_S5P | |||
330 | algorithms execution. | 330 | algorithms execution. |
331 | 331 | ||
332 | config CRYPTO_DEV_NX | 332 | config CRYPTO_DEV_NX |
333 | bool "Support for IBM Power7+ in-Nest cryptographic acceleration" | 333 | bool "Support for IBM PowerPC Nest (NX) cryptographic acceleration" |
334 | depends on PPC64 && IBMVIO && !CPU_LITTLE_ENDIAN | 334 | depends on PPC64 |
335 | default n | ||
336 | help | 335 | help |
337 | Support for Power7+ in-Nest cryptographic acceleration. | 336 | This enables support for the NX hardware cryptographic accelerator |
337 | coprocessor that is in IBM PowerPC P7+ or later processors. This | ||
338 | does not actually enable any drivers, it only allows you to select | ||
339 | which acceleration type (encryption and/or compression) to enable. | ||
338 | 340 | ||
339 | if CRYPTO_DEV_NX | 341 | if CRYPTO_DEV_NX |
340 | source "drivers/crypto/nx/Kconfig" | 342 | source "drivers/crypto/nx/Kconfig" |
diff --git a/drivers/crypto/nx/Kconfig b/drivers/crypto/nx/Kconfig index f82616621ae1..34013f7d46c8 100644 --- a/drivers/crypto/nx/Kconfig +++ b/drivers/crypto/nx/Kconfig | |||
@@ -1,7 +1,9 @@ | |||
1 | |||
1 | config CRYPTO_DEV_NX_ENCRYPT | 2 | config CRYPTO_DEV_NX_ENCRYPT |
2 | tristate "Encryption acceleration support" | 3 | tristate "Encryption acceleration support on pSeries platform" |
3 | depends on PPC64 && IBMVIO | 4 | depends on PPC_PSERIES && IBMVIO && !CPU_LITTLE_ENDIAN |
4 | default y | 5 | default y |
6 | select CRYPTO_ALGAPI | ||
5 | select CRYPTO_AES | 7 | select CRYPTO_AES |
6 | select CRYPTO_CBC | 8 | select CRYPTO_CBC |
7 | select CRYPTO_ECB | 9 | select CRYPTO_ECB |
@@ -12,15 +14,30 @@ config CRYPTO_DEV_NX_ENCRYPT | |||
12 | select CRYPTO_SHA256 | 14 | select CRYPTO_SHA256 |
13 | select CRYPTO_SHA512 | 15 | select CRYPTO_SHA512 |
14 | help | 16 | help |
15 | Support for Power7+ in-Nest encryption acceleration. This | 17 | Support for PowerPC Nest (NX) encryption acceleration. This |
16 | module supports acceleration for AES and SHA2 algorithms. If you | 18 | module supports acceleration for AES and SHA2 algorithms on |
17 | choose 'M' here, this module will be called nx_crypto. | 19 | the pSeries platform. If you choose 'M' here, this module |
20 | will be called nx_crypto. | ||
18 | 21 | ||
19 | config CRYPTO_DEV_NX_COMPRESS | 22 | config CRYPTO_DEV_NX_COMPRESS |
20 | tristate "Compression acceleration support" | 23 | tristate "Compression acceleration support" |
21 | depends on PPC64 && IBMVIO | ||
22 | default y | 24 | default y |
23 | help | 25 | help |
24 | Support for Power7+ in-Nest compression acceleration. This | 26 | Support for PowerPC Nest (NX) compression acceleration. This |
25 | module supports acceleration for AES and SHA2 algorithms. If you | 27 | module supports acceleration for compressing memory with the 842 |
26 | choose 'M' here, this module will be called nx_compress. | 28 | algorithm. One of the platform drivers must be selected also. |
29 | If you choose 'M' here, this module will be called nx_compress. | ||
30 | |||
31 | if CRYPTO_DEV_NX_COMPRESS | ||
32 | |||
33 | config CRYPTO_DEV_NX_COMPRESS_PSERIES | ||
34 | tristate "Compression acceleration support on pSeries platform" | ||
35 | depends on PPC_PSERIES && IBMVIO && !CPU_LITTLE_ENDIAN | ||
36 | default y | ||
37 | help | ||
38 | Support for PowerPC Nest (NX) compression acceleration. This | ||
39 | module supports acceleration for compressing memory with the 842 | ||
40 | algorithm. This supports NX hardware on the pSeries platform. | ||
41 | If you choose 'M' here, this module will be called nx_compress_pseries. | ||
42 | |||
43 | endif | ||
diff --git a/drivers/crypto/nx/Makefile b/drivers/crypto/nx/Makefile index 8669ffa8dc5c..5d9f4bc15209 100644 --- a/drivers/crypto/nx/Makefile +++ b/drivers/crypto/nx/Makefile | |||
@@ -11,4 +11,6 @@ nx-crypto-objs := nx.o \ | |||
11 | nx-sha512.o | 11 | nx-sha512.o |
12 | 12 | ||
13 | obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS) += nx-compress.o | 13 | obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS) += nx-compress.o |
14 | nx-compress-objs := nx-842-pseries.o | 14 | obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS_PSERIES) += nx-compress-pseries.o |
15 | nx-compress-objs := nx-842.o | ||
16 | nx-compress-pseries-objs := nx-842-pseries.o | ||
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 | ||
diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c new file mode 100644 index 000000000000..f1f378eef373 --- /dev/null +++ b/drivers/crypto/nx/nx-842.c | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | * Driver frontend for IBM Power 842 compression accelerator | ||
3 | * | ||
4 | * Copyright (C) 2015 Dan Streetman, IBM Corp | ||
5 | * | ||
6 | * Designer of the Power data compression engine: | ||
7 | * Bulent Abali <abali@us.ibm.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
21 | |||
22 | #include "nx-842.h" | ||
23 | |||
24 | #define MODULE_NAME "nx-compress" | ||
25 | MODULE_LICENSE("GPL"); | ||
26 | MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>"); | ||
27 | MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); | ||
28 | |||
29 | /* Only one driver is expected, based on the HW platform */ | ||
30 | static struct nx842_driver *nx842_driver; | ||
31 | static DEFINE_SPINLOCK(nx842_driver_lock); /* protects driver pointers */ | ||
32 | |||
33 | void nx842_register_driver(struct nx842_driver *driver) | ||
34 | { | ||
35 | spin_lock(&nx842_driver_lock); | ||
36 | |||
37 | if (nx842_driver) { | ||
38 | pr_err("can't register driver %s, already using driver %s\n", | ||
39 | driver->owner->name, nx842_driver->owner->name); | ||
40 | } else { | ||
41 | pr_info("registering driver %s\n", driver->owner->name); | ||
42 | nx842_driver = driver; | ||
43 | } | ||
44 | |||
45 | spin_unlock(&nx842_driver_lock); | ||
46 | } | ||
47 | EXPORT_SYMBOL_GPL(nx842_register_driver); | ||
48 | |||
49 | void nx842_unregister_driver(struct nx842_driver *driver) | ||
50 | { | ||
51 | spin_lock(&nx842_driver_lock); | ||
52 | |||
53 | if (nx842_driver == driver) { | ||
54 | pr_info("unregistering driver %s\n", driver->owner->name); | ||
55 | nx842_driver = NULL; | ||
56 | } else if (nx842_driver) { | ||
57 | pr_err("can't unregister driver %s, using driver %s\n", | ||
58 | driver->owner->name, nx842_driver->owner->name); | ||
59 | } else { | ||
60 | pr_err("can't unregister driver %s, no driver in use\n", | ||
61 | driver->owner->name); | ||
62 | } | ||
63 | |||
64 | spin_unlock(&nx842_driver_lock); | ||
65 | } | ||
66 | EXPORT_SYMBOL_GPL(nx842_unregister_driver); | ||
67 | |||
68 | static struct nx842_driver *get_driver(void) | ||
69 | { | ||
70 | struct nx842_driver *driver = NULL; | ||
71 | |||
72 | spin_lock(&nx842_driver_lock); | ||
73 | |||
74 | driver = nx842_driver; | ||
75 | |||
76 | if (driver && !try_module_get(driver->owner)) | ||
77 | driver = NULL; | ||
78 | |||
79 | spin_unlock(&nx842_driver_lock); | ||
80 | |||
81 | return driver; | ||
82 | } | ||
83 | |||
84 | static void put_driver(struct nx842_driver *driver) | ||
85 | { | ||
86 | module_put(driver->owner); | ||
87 | } | ||
88 | |||
89 | int nx842_compress(const unsigned char *in, unsigned int in_len, | ||
90 | unsigned char *out, unsigned int *out_len, | ||
91 | void *wrkmem) | ||
92 | { | ||
93 | struct nx842_driver *driver = get_driver(); | ||
94 | int ret; | ||
95 | |||
96 | if (!driver) | ||
97 | return -ENODEV; | ||
98 | |||
99 | ret = driver->compress(in, in_len, out, out_len, wrkmem); | ||
100 | |||
101 | put_driver(driver); | ||
102 | |||
103 | return ret; | ||
104 | } | ||
105 | EXPORT_SYMBOL_GPL(nx842_compress); | ||
106 | |||
107 | int nx842_decompress(const unsigned char *in, unsigned int in_len, | ||
108 | unsigned char *out, unsigned int *out_len, | ||
109 | void *wrkmem) | ||
110 | { | ||
111 | struct nx842_driver *driver = get_driver(); | ||
112 | int ret; | ||
113 | |||
114 | if (!driver) | ||
115 | return -ENODEV; | ||
116 | |||
117 | ret = driver->decompress(in, in_len, out, out_len, wrkmem); | ||
118 | |||
119 | put_driver(driver); | ||
120 | |||
121 | return ret; | ||
122 | } | ||
123 | EXPORT_SYMBOL_GPL(nx842_decompress); | ||
124 | |||
125 | static __init int nx842_init(void) | ||
126 | { | ||
127 | pr_info("loading\n"); | ||
128 | |||
129 | if (of_find_compatible_node(NULL, NULL, NX842_PSERIES_COMPAT_NAME)) | ||
130 | request_module_nowait(NX842_PSERIES_MODULE_NAME); | ||
131 | else | ||
132 | pr_err("no nx842 driver found.\n"); | ||
133 | |||
134 | pr_info("loaded\n"); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | module_init(nx842_init); | ||
139 | |||
140 | static void __exit nx842_exit(void) | ||
141 | { | ||
142 | pr_info("NX842 unloaded\n"); | ||
143 | } | ||
144 | module_exit(nx842_exit); | ||
diff --git a/drivers/crypto/nx/nx-842.h b/drivers/crypto/nx/nx-842.h new file mode 100644 index 000000000000..2a5d4e197c72 --- /dev/null +++ b/drivers/crypto/nx/nx-842.h | |||
@@ -0,0 +1,32 @@ | |||
1 | |||
2 | #ifndef __NX_842_H__ | ||
3 | #define __NX_842_H__ | ||
4 | |||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/module.h> | ||
7 | #include <linux/nx842.h> | ||
8 | #include <linux/of.h> | ||
9 | #include <linux/slab.h> | ||
10 | #include <linux/io.h> | ||
11 | |||
12 | struct nx842_driver { | ||
13 | struct module *owner; | ||
14 | |||
15 | int (*compress)(const unsigned char *in, unsigned int in_len, | ||
16 | unsigned char *out, unsigned int *out_len, | ||
17 | void *wrkmem); | ||
18 | int (*decompress)(const unsigned char *in, unsigned int in_len, | ||
19 | unsigned char *out, unsigned int *out_len, | ||
20 | void *wrkmem); | ||
21 | }; | ||
22 | |||
23 | void nx842_register_driver(struct nx842_driver *driver); | ||
24 | void nx842_unregister_driver(struct nx842_driver *driver); | ||
25 | |||
26 | |||
27 | /* To allow the main nx-compress module to load platform module */ | ||
28 | #define NX842_PSERIES_MODULE_NAME "nx-compress-pseries" | ||
29 | #define NX842_PSERIES_COMPAT_NAME "ibm,compression" | ||
30 | |||
31 | |||
32 | #endif /* __NX_842_H__ */ | ||
diff --git a/include/linux/nx842.h b/include/linux/nx842.h index a4d324c6406a..d919c22b7fd6 100644 --- a/include/linux/nx842.h +++ b/include/linux/nx842.h | |||
@@ -1,11 +1,13 @@ | |||
1 | #ifndef __NX842_H__ | 1 | #ifndef __NX842_H__ |
2 | #define __NX842_H__ | 2 | #define __NX842_H__ |
3 | 3 | ||
4 | int nx842_get_workmem_size(void); | 4 | #define __NX842_PSERIES_MEM_COMPRESS ((PAGE_SIZE * 2) + 10240) |
5 | int nx842_get_workmem_size_aligned(void); | 5 | |
6 | #define NX842_MEM_COMPRESS __NX842_PSERIES_MEM_COMPRESS | ||
7 | |||
6 | int nx842_compress(const unsigned char *in, unsigned int in_len, | 8 | int nx842_compress(const unsigned char *in, unsigned int in_len, |
7 | unsigned char *out, unsigned int *out_len, void *wrkmem); | 9 | unsigned char *out, unsigned int *out_len, void *wrkmem); |
8 | int nx842_decompress(const unsigned char *in, unsigned int in_len, | 10 | int nx842_decompress(const unsigned char *in, unsigned int in_len, |
9 | unsigned char *out, unsigned int *out_len, void *wrkmem); | 11 | unsigned char *out, unsigned int *out_len, void *wrkmem); |
10 | 12 | ||
11 | #endif | 13 | #endif |