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