^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2014 Sergey Senozhatsky.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef _ZCOMP_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define _ZCOMP_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/local_lock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct zcomp_strm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /* The members ->buffer and ->tfm are protected by ->lock. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) local_lock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* compression/decompression buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) void *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct crypto_comp *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* dynamic per-device compression frontend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct zcomp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct zcomp_strm __percpu *stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct hlist_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ssize_t zcomp_available_show(const char *comp, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) bool zcomp_available_algorithm(const char *comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct zcomp *zcomp_create(const char *comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void zcomp_destroy(struct zcomp *comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void zcomp_stream_put(struct zcomp *comp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int zcomp_compress(struct zcomp_strm *zstrm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) const void *src, unsigned int *dst_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int zcomp_decompress(struct zcomp_strm *zstrm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) const void *src, unsigned int src_len, void *dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif /* _ZCOMP_H_ */