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