1 /* SPDX-License-Identifier: GPL-2.0-or-later */
6 #include <linux/local_lock.h>
8 #define ZCOMP_PARAM_NO_LEVEL INT_MIN
11 * Immutable driver (backend) parameters. The driver may attach private
12 * data to it (e.g. driver representation of the dictionary, etc.).
14 * This data is kept per-comp and is shared among execution contexts.
25 * Run-time driver context - scratch buffers, etc. It is modified during
26 * request execution (compression/decompression), cannot be shared, so
27 * it's in per-CPU area.
35 /* compression buffer */
41 const unsigned char *src
;
49 int (*compress
)(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
,
50 struct zcomp_req
*req
);
51 int (*decompress
)(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
,
52 struct zcomp_req
*req
);
54 int (*create_ctx
)(struct zcomp_params
*params
, struct zcomp_ctx
*ctx
);
55 void (*destroy_ctx
)(struct zcomp_ctx
*ctx
);
57 int (*setup_params
)(struct zcomp_params
*params
);
58 void (*release_params
)(struct zcomp_params
*params
);
63 /* dynamic per-device compression frontend */
65 struct zcomp_strm __percpu
*stream
;
66 const struct zcomp_ops
*ops
;
67 struct zcomp_params
*params
;
68 struct hlist_node node
;
71 int zcomp_cpu_up_prepare(unsigned int cpu
, struct hlist_node
*node
);
72 int zcomp_cpu_dead(unsigned int cpu
, struct hlist_node
*node
);
73 ssize_t
zcomp_available_show(const char *comp
, char *buf
);
74 bool zcomp_available_algorithm(const char *comp
);
76 struct zcomp
*zcomp_create(const char *alg
, struct zcomp_params
*params
);
77 void zcomp_destroy(struct zcomp
*comp
);
79 struct zcomp_strm
*zcomp_stream_get(struct zcomp
*comp
);
80 void zcomp_stream_put(struct zcomp
*comp
);
82 int zcomp_compress(struct zcomp
*comp
, struct zcomp_strm
*zstrm
,
83 const void *src
, unsigned int *dst_len
);
84 int zcomp_decompress(struct zcomp
*comp
, struct zcomp_strm
*zstrm
,
85 const void *src
, unsigned int src_len
, void *dst
);
87 #endif /* _ZCOMP_H_ */