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 #define LB_SIZE_4K 0x1000UL 42 #define LB_SIZE_512B 0x200UL 43 44 /** 45 * Get the first compression bdev. 46 * 47 * \return the first compression bdev. 48 */ 49 struct vbdev_compress *compress_bdev_first(void); 50 51 /** 52 * Get the next compression bdev. 53 * 54 * \param prev previous compression bdev. 55 * \return the next compression bdev. 56 */ 57 struct vbdev_compress *compress_bdev_next(struct vbdev_compress *prev); 58 59 /** 60 * Test to see if a compression bdev orphan exists. 61 * 62 * \param name The name of the compression bdev. 63 * \return true if found, false if not. 64 */ 65 bool compress_has_orphan(const char *name); 66 67 /** 68 * Get the name of a compression bdev. 69 * 70 * \param comp_bdev The compression bdev. 71 * \return the name of the compression bdev. 72 */ 73 const char *compress_get_name(const struct vbdev_compress *comp_bdev); 74 75 enum compress_pmd { 76 COMPRESS_PMD_AUTO = 0, 77 COMPRESS_PMD_QAT_ONLY, 78 COMPRESS_PMD_ISAL_ONLY, 79 COMPRESS_PMD_MAX 80 }; 81 82 int compress_set_pmd(enum compress_pmd *opts); 83 84 typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno); 85 86 /** 87 * Create new compression bdev. 88 * 89 * \param bdev_name Bdev on which compression bdev will be created. 90 * \param pm_path Path to persistent memory. 91 * \param lb_size Logical block size for the compressed volume in bytes. Must be 4K or 512. 92 * \return 0 on success, other on failure. 93 */ 94 int create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size); 95 96 /** 97 * Delete compress bdev. 98 * 99 * \param bdev_name Bdev on which compression bdev will be deleted. 100 * \param cb_fn Function to call after deletion. 101 * \param cb_arg Argument to pass to cb_fn. 102 */ 103 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn, 104 void *cb_arg); 105 106 #endif /* SPDK_VBDEV_COMPRESS_H */ 107