xref: /openbmc/linux/drivers/block/zram/zcomp.h (revision a61127c2)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2014 Sergey Senozhatsky.
4  */
5 
6 #ifndef _ZCOMP_H_
7 #define _ZCOMP_H_
8 
9 struct zcomp_strm {
10 	/* compression/decompression buffer */
11 	void *buffer;
12 	struct crypto_comp *tfm;
13 };
14 
15 /* dynamic per-device compression frontend */
16 struct zcomp {
17 	struct zcomp_strm * __percpu *stream;
18 	const char *name;
19 	struct hlist_node node;
20 };
21 
22 int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
23 int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
24 ssize_t zcomp_available_show(const char *comp, char *buf);
25 bool zcomp_available_algorithm(const char *comp);
26 
27 struct zcomp *zcomp_create(const char *comp);
28 void zcomp_destroy(struct zcomp *comp);
29 
30 struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
31 void zcomp_stream_put(struct zcomp *comp);
32 
33 int zcomp_compress(struct zcomp_strm *zstrm,
34 		const void *src, unsigned int *dst_len);
35 
36 int zcomp_decompress(struct zcomp_strm *zstrm,
37 		const void *src, unsigned int src_len, void *dst);
38 
39 bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
40 #endif /* _ZCOMP_H_ */
41