]>
Commit | Line | Data |
---|---|---|
7011a122 DS |
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 | ||
7011a122 DS |
24 | MODULE_LICENSE("GPL"); |
25 | MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>"); | |
26 | MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); | |
27 | ||
959e6659 DS |
28 | /** |
29 | * nx842_constraints | |
30 | * | |
31 | * This provides the driver's constraints. Different nx842 implementations | |
32 | * may have varying requirements. The constraints are: | |
33 | * @alignment: All buffers should be aligned to this | |
34 | * @multiple: All buffer lengths should be a multiple of this | |
35 | * @minimum: Buffer lengths must not be less than this amount | |
36 | * @maximum: Buffer lengths must not be more than this amount | |
37 | * | |
38 | * The constraints apply to all buffers and lengths, both input and output, | |
39 | * for both compression and decompression, except for the minimum which | |
40 | * only applies to compression input and decompression output; the | |
41 | * compressed data can be less than the minimum constraint. It can be | |
42 | * assumed that compressed data will always adhere to the multiple | |
43 | * constraint. | |
44 | * | |
45 | * The driver may succeed even if these constraints are violated; | |
46 | * however the driver can return failure or suffer reduced performance | |
47 | * if any constraint is not met. | |
48 | */ | |
49 | int nx842_constraints(struct nx842_constraints *c) | |
50 | { | |
3e648cbe DS |
51 | memcpy(c, nx842_platform_driver()->constraints, sizeof(*c)); |
52 | return 0; | |
959e6659 DS |
53 | } |
54 | EXPORT_SYMBOL_GPL(nx842_constraints); | |
55 | ||
2c6f6eab DS |
56 | /** |
57 | * nx842_workmem_size | |
58 | * | |
59 | * Get the amount of working memory the driver requires. | |
60 | */ | |
61 | size_t nx842_workmem_size(void) | |
62 | { | |
63 | return nx842_platform_driver()->workmem_size; | |
64 | } | |
65 | EXPORT_SYMBOL_GPL(nx842_workmem_size); | |
66 | ||
3e648cbe DS |
67 | int nx842_compress(const unsigned char *in, unsigned int ilen, |
68 | unsigned char *out, unsigned int *olen, void *wmem) | |
7011a122 | 69 | { |
3e648cbe | 70 | return nx842_platform_driver()->compress(in, ilen, out, olen, wmem); |
7011a122 DS |
71 | } |
72 | EXPORT_SYMBOL_GPL(nx842_compress); | |
73 | ||
3e648cbe DS |
74 | int nx842_decompress(const unsigned char *in, unsigned int ilen, |
75 | unsigned char *out, unsigned int *olen, void *wmem) | |
7011a122 | 76 | { |
3e648cbe | 77 | return nx842_platform_driver()->decompress(in, ilen, out, olen, wmem); |
7011a122 DS |
78 | } |
79 | EXPORT_SYMBOL_GPL(nx842_decompress); | |
80 | ||
81 | static __init int nx842_init(void) | |
82 | { | |
3e648cbe DS |
83 | request_module("nx-compress-powernv"); |
84 | request_module("nx-compress-pseries"); | |
85 | ||
86 | /* we prevent loading if there's no platform driver, and we get the | |
87 | * module that set it so it won't unload, so we don't need to check | |
88 | * if it's set in any of the above functions | |
89 | */ | |
90 | if (!nx842_platform_driver_get()) { | |
7011a122 | 91 | pr_err("no nx842 driver found.\n"); |
3e648cbe DS |
92 | return -ENODEV; |
93 | } | |
7011a122 DS |
94 | |
95 | return 0; | |
96 | } | |
97 | module_init(nx842_init); | |
98 | ||
99 | static void __exit nx842_exit(void) | |
100 | { | |
3e648cbe | 101 | nx842_platform_driver_put(); |
7011a122 DS |
102 | } |
103 | module_exit(nx842_exit); |