1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2023 Solidigm All Rights Reserved 3 */ 4 5 #ifndef FTL_NV_CACHE_DEVICE_H 6 #define FTL_NV_CACHE_DEVICE_H 7 8 #include "spdk/stdinc.h" 9 #include "spdk/bdev_module.h" 10 11 struct spdk_ftl_dev; 12 struct ftl_mngt_process; 13 14 /** 15 * @brief NV Cache device features and capabilities 16 */ 17 struct ftl_nv_cache_device_features { 18 /* 19 * The placeholder for NV Cache device features. It will be filled in the future. 20 */ 21 }; 22 23 /** 24 * @brief NV Cache device operations interface 25 */ 26 struct ftl_nv_cache_device_ops { 27 /** 28 * @brief Check if block device is valid for NV Cache device 29 * 30 * @param dev ftl device 31 * @param bdev bdev to be checked 32 * 33 * @retval true if bdev is valid for NV Cache device 34 * @retval false if bdev is not valid for NV Cache device 35 */ 36 bool (*is_bdev_compatible)(struct spdk_ftl_dev *dev, struct spdk_bdev *bdev); 37 }; 38 39 /** 40 * @brief NV Cache device descriptor 41 */ 42 struct ftl_nv_cache_device_desc { 43 /** 44 * The name of the NV cache device type 45 */ 46 const char *name; 47 48 /** 49 * The features list of the NV cache device type 50 * 51 */ 52 const struct ftl_nv_cache_device_features features; 53 54 /** 55 * The NV cache device operations 56 */ 57 const struct ftl_nv_cache_device_ops ops; 58 59 /** Internal fields */ 60 struct { 61 /* The queue entry to put this description to a queue */ 62 TAILQ_ENTRY(ftl_nv_cache_device_desc) entry; 63 } internal; 64 }; 65 66 /** 67 * @brief Macro to register NV Cache device type when the module is loaded 68 * 69 * @param desc NV Cache device type descriptor 70 */ 71 #define FTL_NV_CACHE_DEVICE_TYPE_REGISTER(desc) \ 72 static void __attribute__((constructor)) ftl_nv_cache_device_register_##desc(void) \ 73 { \ 74 ftl_nv_cache_device_register(&desc); \ 75 } 76 77 /** 78 * @brief Register NV Cache device type 79 * 80 * @param desc NV Cache device type descriptor 81 */ 82 void ftl_nv_cache_device_register(struct ftl_nv_cache_device_desc *desc); 83 84 /** 85 * @brief Get NV Cache device type descriptor by bdev 86 * 87 * @param bdev bdev for which NV Cache device type descriptor is requested 88 * 89 * @return NV Cache device type descriptor 90 */ 91 const struct ftl_nv_cache_device_desc *ftl_nv_cache_device_get_desc_by_bdev( 92 struct spdk_ftl_dev *dev, struct spdk_bdev *bdev); 93 94 #endif /* FTL_NV_CACHE_DEVICE_H */ 95