xref: /spdk/module/bdev/compress/vbdev_compress.h (revision 307b8c112ffd90a26d53dd15fad67bd9038ef526)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (c) Intel Corporation.
3  *   All rights reserved.
4  *   Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
5  */
6 
7 #ifndef SPDK_VBDEV_COMPRESS_H
8 #define SPDK_VBDEV_COMPRESS_H
9 
10 #include "spdk/stdinc.h"
11 
12 #include "spdk/bdev.h"
13 
14 #define LB_SIZE_4K	0x1000UL
15 #define LB_SIZE_512B	0x200UL
16 
17 /**
18  * Get the first compression bdev.
19  *
20  * \return the first compression bdev.
21  */
22 struct vbdev_compress *compress_bdev_first(void);
23 
24 /**
25  * Get the next compression bdev.
26  *
27  * \param prev previous compression bdev.
28  * \return the next compression bdev.
29  */
30 struct vbdev_compress *compress_bdev_next(struct vbdev_compress *prev);
31 
32 /**
33  * Test to see if a compression bdev orphan exists.
34  *
35  * \param name The name of the compression bdev.
36  * \return true if found, false if not.
37  */
38 bool compress_has_orphan(const char *name);
39 
40 /**
41  * Get the name of a compression bdev.
42  *
43  * \param comp_bdev The compression bdev.
44  * \return the name of the compression bdev.
45  */
46 const char *compress_get_name(const struct vbdev_compress *comp_bdev);
47 
48 enum compress_pmd {
49 	COMPRESS_PMD_AUTO = 0,
50 	COMPRESS_PMD_QAT_ONLY,
51 	COMPRESS_PMD_ISAL_ONLY,
52 	COMPRESS_PMD_MLX5_PCI_ONLY,
53 	COMPRESS_PMD_MAX
54 };
55 
56 int compress_set_pmd(enum compress_pmd *opts);
57 
58 typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno);
59 
60 /**
61  * Create new compression bdev.
62  *
63  * \param bdev_name Bdev on which compression bdev will be created.
64  * \param pm_path Path to persistent memory.
65  * \param lb_size Logical block size for the compressed volume in bytes. Must be 4K or 512.
66  * \return 0 on success, other on failure.
67  */
68 int create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size);
69 
70 /**
71  * Delete compress bdev.
72  *
73  * \param bdev_name Bdev on which compression bdev will be deleted.
74  * \param cb_fn Function to call after deletion.
75  * \param cb_arg Argument to pass to cb_fn.
76  */
77 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn,
78 			  void *cb_arg);
79 
80 #endif /* SPDK_VBDEV_COMPRESS_H */
81