2 * Driver frontend for IBM Power 842 compression accelerator
4 * Copyright (C) 2015 Dan Streetman, IBM Corp
6 * Designer of the Power data compression engine:
7 * Bulent Abali <abali@us.ibm.com>
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.
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.
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 MODULE_LICENSE("GPL");
25 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
26 MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors");
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
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
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.
49 int nx842_constraints(struct nx842_constraints
*c
)
51 memcpy(c
, nx842_platform_driver()->constraints
, sizeof(*c
));
54 EXPORT_SYMBOL_GPL(nx842_constraints
);
59 * Get the amount of working memory the driver requires.
61 size_t nx842_workmem_size(void)
63 return nx842_platform_driver()->workmem_size
;
65 EXPORT_SYMBOL_GPL(nx842_workmem_size
);
67 int nx842_compress(const unsigned char *in
, unsigned int ilen
,
68 unsigned char *out
, unsigned int *olen
, void *wmem
)
70 return nx842_platform_driver()->compress(in
, ilen
, out
, olen
, wmem
);
72 EXPORT_SYMBOL_GPL(nx842_compress
);
74 int nx842_decompress(const unsigned char *in
, unsigned int ilen
,
75 unsigned char *out
, unsigned int *olen
, void *wmem
)
77 return nx842_platform_driver()->decompress(in
, ilen
, out
, olen
, wmem
);
79 EXPORT_SYMBOL_GPL(nx842_decompress
);
81 static __init
int nx842_init(void)
83 request_module("nx-compress-powernv");
84 request_module("nx-compress-pseries");
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
90 if (!nx842_platform_driver_get()) {
91 pr_err("no nx842 driver found.\n");
97 module_init(nx842_init
);
99 static void __exit
nx842_exit(void)
101 nx842_platform_driver_put();
103 module_exit(nx842_exit
);