Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2014 Sergey Senozhatsky.
0004  */
0005 
0006 #ifndef _ZCOMP_H_
0007 #define _ZCOMP_H_
0008 #include <linux/local_lock.h>
0009 
0010 struct zcomp_strm {
0011     /* The members ->buffer and ->tfm are protected by ->lock. */
0012     local_lock_t lock;
0013     /* compression/decompression buffer */
0014     void *buffer;
0015     struct crypto_comp *tfm;
0016 };
0017 
0018 /* dynamic per-device compression frontend */
0019 struct zcomp {
0020     struct zcomp_strm __percpu *stream;
0021     const char *name;
0022     struct hlist_node node;
0023 };
0024 
0025 int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
0026 int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
0027 ssize_t zcomp_available_show(const char *comp, char *buf);
0028 bool zcomp_available_algorithm(const char *comp);
0029 
0030 struct zcomp *zcomp_create(const char *comp);
0031 void zcomp_destroy(struct zcomp *comp);
0032 
0033 struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
0034 void zcomp_stream_put(struct zcomp *comp);
0035 
0036 int zcomp_compress(struct zcomp_strm *zstrm,
0037         const void *src, unsigned int *dst_len);
0038 
0039 int zcomp_decompress(struct zcomp_strm *zstrm,
0040         const void *src, unsigned int src_len, void *dst);
0041 
0042 bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
0043 #endif /* _ZCOMP_H_ */