Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 Sergey Senozhatsky. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version |
| 7 | * 2 of the License, or (at your option) any later version. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _ZCOMP_H_ |
| 11 | #define _ZCOMP_H_ |
| 12 | |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 13 | struct zcomp_strm { |
| 14 | /* compression/decompression buffer */ |
| 15 | void *buffer; |
Sergey Senozhatsky | ebaf9ab | 2016-07-26 15:22:45 -0700 | [diff] [blame] | 16 | struct crypto_comp *tfm; |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 17 | }; |
| 18 | |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 19 | /* dynamic per-device compression frontend */ |
| 20 | struct zcomp { |
Sergey Senozhatsky | da9556a | 2016-05-20 16:59:51 -0700 | [diff] [blame] | 21 | struct zcomp_strm * __percpu *stream; |
Sergey Senozhatsky | ebaf9ab | 2016-07-26 15:22:45 -0700 | [diff] [blame] | 22 | const char *name; |
Anna-Maria Gleixner | 1dd6c83 | 2016-11-27 00:13:46 +0100 | [diff] [blame] | 23 | struct hlist_node node; |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
Anna-Maria Gleixner | 1dd6c83 | 2016-11-27 00:13:46 +0100 | [diff] [blame] | 26 | int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node); |
| 27 | int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node); |
Sergey Senozhatsky | e46b8a0 | 2014-04-07 15:38:17 -0700 | [diff] [blame] | 28 | ssize_t zcomp_available_show(const char *comp, char *buf); |
Sergey Senozhatsky | d93435c | 2015-06-25 15:00:32 -0700 | [diff] [blame] | 29 | bool zcomp_available_algorithm(const char *comp); |
Sergey Senozhatsky | e46b8a0 | 2014-04-07 15:38:17 -0700 | [diff] [blame] | 30 | |
Sergey Senozhatsky | da9556a | 2016-05-20 16:59:51 -0700 | [diff] [blame] | 31 | struct zcomp *zcomp_create(const char *comp); |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 32 | void zcomp_destroy(struct zcomp *comp); |
| 33 | |
Sergey Senozhatsky | 2aea849 | 2016-07-26 15:22:42 -0700 | [diff] [blame] | 34 | struct zcomp_strm *zcomp_stream_get(struct zcomp *comp); |
| 35 | void zcomp_stream_put(struct zcomp *comp); |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 36 | |
Sergey Senozhatsky | ebaf9ab | 2016-07-26 15:22:45 -0700 | [diff] [blame] | 37 | int zcomp_compress(struct zcomp_strm *zstrm, |
| 38 | const void *src, unsigned int *dst_len); |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 39 | |
Sergey Senozhatsky | ebaf9ab | 2016-07-26 15:22:45 -0700 | [diff] [blame] | 40 | int zcomp_decompress(struct zcomp_strm *zstrm, |
| 41 | const void *src, unsigned int src_len, void *dst); |
Sergey Senozhatsky | fe8eb12 | 2014-04-07 15:38:15 -0700 | [diff] [blame] | 42 | |
Minchan Kim | 60a726e | 2014-04-07 15:38:21 -0700 | [diff] [blame] | 43 | bool zcomp_set_max_streams(struct zcomp *comp, int num_strm); |
Sergey Senozhatsky | e7e1ef4 | 2014-04-07 15:38:11 -0700 | [diff] [blame] | 44 | #endif /* _ZCOMP_H_ */ |