xref: /spdk/module/bdev/compress/vbdev_compress.h (revision 94a84ae98590bea46939eb1dcd7a9876bd393b54)
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) Intel Corporation.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef SPDK_VBDEV_COMPRESS_H
35 #define SPDK_VBDEV_COMPRESS_H
36 
37 #include "spdk/stdinc.h"
38 
39 #include "spdk/bdev.h"
40 
41 /**
42  * Get the first compression bdev.
43  *
44  * \return the first compression bdev.
45  */
46 struct vbdev_compress *compress_bdev_first(void);
47 
48 /**
49  * Get the next compression bdev.
50  *
51  * \param prev previous compression bdev.
52  * \return the next compression bdev.
53  */
54 struct vbdev_compress *compress_bdev_next(struct vbdev_compress *prev);
55 
56 /**
57  * Test to see if a compression bdev orphan exists.
58  *
59  * \param name The name of the compression bdev.
60  * \return true if found, false if not.
61  */
62 bool compress_has_orphan(const char *name);
63 
64 /**
65  * Get the name of a compression bdev.
66  *
67  * \param comp_bdev The compression bdev.
68  * \return the name of the compression bdev.
69  */
70 const char *compress_get_name(const struct vbdev_compress *comp_bdev);
71 
72 enum compress_pmd {
73 	COMPRESS_PMD_AUTO = 0,
74 	COMPRESS_PMD_QAT_ONLY,
75 	COMPRESS_PMD_ISAL_ONLY,
76 	COMPRESS_PMD_MAX
77 };
78 
79 int compress_set_pmd(enum compress_pmd *opts);
80 
81 typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno);
82 
83 /**
84  * Create new compression bdev.
85  *
86  * \param bdev_name Bdev on which compression bdev will be created.
87  * \param pm_path Path to persistent memory.
88  * \return 0 on success, other on failure.
89  */
90 int create_compress_bdev(const char *bdev_name, const char *pm_path);
91 
92 /**
93  * Delete compress bdev.
94  *
95  * \param bdev_name Bdev on which compression bdev will be deleted.
96  * \param cb_fn Function to call after deletion.
97  * \param cb_arg Argument to pass to cb_fn.
98  */
99 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn,
100 			  void *cb_arg);
101 
102 #endif /* SPDK_VBDEV_COMPRESS_H */
103