blob: 41c1002a7d7dffc4ec0c458a0e0f1d68fb5f1a3a [file] [log] [blame]
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -07001/*
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 Senozhatskye7e1ef42014-04-07 15:38:11 -070013struct zcomp_strm {
14 /* compression/decompression buffer */
15 void *buffer;
Sergey Senozhatskyebaf9ab2016-07-26 15:22:45 -070016 struct crypto_comp *tfm;
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070017};
18
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070019/* dynamic per-device compression frontend */
20struct zcomp {
Sergey Senozhatskyda9556a2016-05-20 16:59:51 -070021 struct zcomp_strm * __percpu *stream;
Sergey Senozhatskyebaf9ab2016-07-26 15:22:45 -070022 const char *name;
Anna-Maria Gleixner1dd6c832016-11-27 00:13:46 +010023 struct hlist_node node;
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070024};
25
Anna-Maria Gleixner1dd6c832016-11-27 00:13:46 +010026int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
27int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
Sergey Senozhatskye46b8a02014-04-07 15:38:17 -070028ssize_t zcomp_available_show(const char *comp, char *buf);
Sergey Senozhatskyd93435c2015-06-25 15:00:32 -070029bool zcomp_available_algorithm(const char *comp);
Sergey Senozhatskye46b8a02014-04-07 15:38:17 -070030
Sergey Senozhatskyda9556a2016-05-20 16:59:51 -070031struct zcomp *zcomp_create(const char *comp);
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070032void zcomp_destroy(struct zcomp *comp);
33
Sergey Senozhatsky2aea8492016-07-26 15:22:42 -070034struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
35void zcomp_stream_put(struct zcomp *comp);
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070036
Sergey Senozhatskyebaf9ab2016-07-26 15:22:45 -070037int zcomp_compress(struct zcomp_strm *zstrm,
38 const void *src, unsigned int *dst_len);
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070039
Sergey Senozhatskyebaf9ab2016-07-26 15:22:45 -070040int zcomp_decompress(struct zcomp_strm *zstrm,
41 const void *src, unsigned int src_len, void *dst);
Sergey Senozhatskyfe8eb122014-04-07 15:38:15 -070042
Minchan Kim60a726e2014-04-07 15:38:21 -070043bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
Sergey Senozhatskye7e1ef42014-04-07 15:38:11 -070044#endif /* _ZCOMP_H_ */