2022-06-22 12:54:05 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FTL_CORE_H
|
|
|
|
#define FTL_CORE_H
|
|
|
|
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#include "spdk/uuid.h"
|
|
|
|
#include "spdk/thread.h"
|
|
|
|
#include "spdk/util.h"
|
|
|
|
#include "spdk/likely.h"
|
|
|
|
#include "spdk/queue.h"
|
|
|
|
#include "spdk/ftl.h"
|
|
|
|
#include "spdk/bdev.h"
|
|
|
|
#include "spdk/bdev_zone.h"
|
2022-06-22 12:01:59 +00:00
|
|
|
|
|
|
|
#include "ftl_internal.h"
|
2022-06-21 11:04:00 +00:00
|
|
|
#include "ftl_io.h"
|
2022-06-20 12:28:58 +00:00
|
|
|
#include "ftl_layout.h"
|
2022-06-22 12:01:59 +00:00
|
|
|
#include "utils/ftl_log.h"
|
2022-06-22 12:54:05 +00:00
|
|
|
|
|
|
|
struct spdk_ftl_dev {
|
2022-06-21 13:45:21 +00:00
|
|
|
/* Configuration */
|
|
|
|
struct spdk_ftl_conf conf;
|
2022-06-22 12:54:05 +00:00
|
|
|
|
2022-06-20 12:28:58 +00:00
|
|
|
/* FTL device layout */
|
|
|
|
struct ftl_layout layout;
|
|
|
|
|
2022-06-22 12:54:05 +00:00
|
|
|
/* Underlying device */
|
|
|
|
struct spdk_bdev_desc *base_bdev_desc;
|
|
|
|
|
|
|
|
/* Cache device */
|
|
|
|
struct spdk_bdev_desc *cache_bdev_desc;
|
|
|
|
|
|
|
|
/* Cache VSS metadata size */
|
|
|
|
uint64_t cache_md_size;
|
|
|
|
|
|
|
|
/* Cached properties of the underlying device */
|
|
|
|
uint64_t num_blocks_in_band;
|
|
|
|
uint64_t num_zones_in_band;
|
|
|
|
uint64_t num_blocks_in_zone;
|
|
|
|
bool is_zoned;
|
|
|
|
|
|
|
|
/* Indicates the device is fully initialized */
|
|
|
|
bool initialized;
|
|
|
|
|
|
|
|
/* Indicates the device is about to be stopped */
|
|
|
|
bool halt;
|
|
|
|
|
|
|
|
/* counters for poller busy, include
|
|
|
|
1. nv cache read/write
|
|
|
|
2. metadata read/write
|
|
|
|
3. base bdev read/write */
|
|
|
|
uint64_t io_activity_total;
|
|
|
|
|
|
|
|
/* Number of operational bands */
|
|
|
|
uint64_t num_bands;
|
|
|
|
|
|
|
|
/* Number of free bands */
|
|
|
|
uint64_t num_free;
|
|
|
|
|
|
|
|
/* Size of the l2p table */
|
|
|
|
uint64_t num_lbas;
|
|
|
|
|
|
|
|
/* Metadata size */
|
|
|
|
uint64_t md_size;
|
|
|
|
|
|
|
|
/* Transfer unit size */
|
|
|
|
uint64_t xfer_size;
|
|
|
|
|
|
|
|
/* Inflight IO operations */
|
|
|
|
uint32_t num_inflight;
|
|
|
|
|
|
|
|
/* Thread on which the poller is running */
|
|
|
|
struct spdk_thread *core_thread;
|
|
|
|
|
|
|
|
/* IO channel to the FTL device, used for internal management operations
|
|
|
|
* consuming FTL's external API
|
|
|
|
*/
|
|
|
|
struct spdk_io_channel *ioch;
|
|
|
|
|
|
|
|
/* Underlying device IO channel */
|
|
|
|
struct spdk_io_channel *base_ioch;
|
|
|
|
|
|
|
|
/* Cache IO channel */
|
|
|
|
struct spdk_io_channel *cache_ioch;
|
|
|
|
|
2022-06-21 11:04:41 +00:00
|
|
|
/* Poller */
|
|
|
|
struct spdk_poller *core_poller;
|
|
|
|
|
2022-06-22 12:54:05 +00:00
|
|
|
/* Read submission queue */
|
|
|
|
TAILQ_HEAD(, ftl_io) rd_sq;
|
|
|
|
|
|
|
|
/* Write submission queue */
|
|
|
|
TAILQ_HEAD(, ftl_io) wr_sq;
|
|
|
|
};
|
|
|
|
|
2022-06-21 11:04:41 +00:00
|
|
|
int ftl_core_poller(void *ctx);
|
|
|
|
|
2022-06-21 13:45:21 +00:00
|
|
|
static inline uint64_t
|
|
|
|
ftl_get_num_blocks_in_band(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->num_blocks_in_band;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t
|
|
|
|
ftl_get_num_zones_in_band(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->num_zones_in_band;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t
|
|
|
|
ftl_get_num_blocks_in_zone(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->num_blocks_in_zone;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
ftl_get_write_unit_size(struct spdk_bdev *bdev)
|
|
|
|
{
|
|
|
|
if (spdk_bdev_is_zoned(bdev)) {
|
|
|
|
return spdk_bdev_get_write_unit_size(bdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: this should be passed via input parameter */
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:03:44 +00:00
|
|
|
static inline size_t
|
|
|
|
ftl_get_num_bands(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->num_bands;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t
|
|
|
|
ftl_get_num_zones(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return ftl_get_num_bands(dev) * ftl_get_num_zones_in_band(dev);
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:04:00 +00:00
|
|
|
static inline bool
|
|
|
|
ftl_check_core_thread(const struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->core_thread == spdk_get_thread();
|
|
|
|
}
|
|
|
|
|
2022-06-22 12:54:05 +00:00
|
|
|
#endif /* FTL_CORE_H */
|