1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2020 Intel Corporation. 3 * All rights reserved. 4 * Copyright 2023 Solidigm All Rights Reserved 5 */ 6 7 #ifndef SPDK_BDEV_FTL_H 8 #define SPDK_BDEV_FTL_H 9 10 #include "spdk/stdinc.h" 11 #include "spdk/bdev_module.h" 12 #include "spdk/ftl.h" 13 14 #include "ftl_core.h" 15 16 struct ftl_bdev_info { 17 const char *name; 18 struct spdk_uuid uuid; 19 }; 20 21 struct rpc_ftl_stats_ctx { 22 struct spdk_bdev_desc *ftl_bdev_desc; 23 struct spdk_jsonrpc_request *request; 24 struct ftl_stats ftl_stats; 25 }; 26 27 typedef void (*ftl_bdev_init_fn)(const struct ftl_bdev_info *, void *, int); 28 29 int bdev_ftl_create_bdev(const struct spdk_ftl_conf *conf, ftl_bdev_init_fn cb, void *cb_arg); 30 void bdev_ftl_delete_bdev(const char *name, bool fast_shutdown, spdk_bdev_unregister_cb cb_fn, 31 void *cb_arg); 32 int bdev_ftl_defer_init(const struct spdk_ftl_conf *conf); 33 void bdev_ftl_unmap(const char *name, uint64_t lba, uint64_t num_blocks, spdk_ftl_fn cb_fn, 34 void *cb_arg); 35 36 /** 37 * @brief Get FTL bdev device statistics 38 * 39 * @param name The name of the FTL bdev device 40 * @param cb Callback function when the stats are ready 41 * @param ftl_stats_ctx The context for getting the statistics 42 * 43 * @note In callback function will return the context of rpc_ftl_stats_ctx 44 * and it contains struct ftl_stats 45 */ 46 void bdev_ftl_get_stats(const char *name, spdk_ftl_fn cb, struct rpc_ftl_stats_ctx *ftl_stats_ctx); 47 48 /** 49 * @brief Get FTL bdev device properties 50 * 51 * @param name The name of FTL bdev device 52 * @param cb_fn Callback function when the stats are ready 53 * @param request The JSON request will be filled with the FTL properties 54 * 55 * @note The JSON request will be returned as the context in the callback function 56 */ 57 void bdev_ftl_get_properties(const char *name, spdk_ftl_fn cb_fn, 58 struct spdk_jsonrpc_request *request); 59 60 #endif /* SPDK_BDEV_FTL_H */ 61