ftl: utils
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I3476a7b11e3078da519beb39fd5f49b8e838a238 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13409 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
parent
769984a925
commit
5140958837
@ -11,6 +11,8 @@ SO_MINOR := 0
|
||||
|
||||
CFLAGS += -I.
|
||||
|
||||
FTL_SUBDIRS := utils
|
||||
|
||||
C_SRCS = ftl_core.c
|
||||
|
||||
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map)
|
||||
@ -18,3 +20,14 @@ SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map)
|
||||
LIBNAME = ftl
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
||||
# TODO: This should be handled by spdk.subdirs.mk
|
||||
CLEAN_FTL_SUBDIRS = $(addprefix clean_ftl_, $(FTL_SUBDIRS))
|
||||
|
||||
clean: $(CLEAN_FTL_SUBDIRS)
|
||||
|
||||
.PHONY: $(CLEAN_FTL_SUBDIRS)
|
||||
$(CLEAN_FTL_SUBDIRS): _Q := $(Q)
|
||||
$(CLEAN_FTL_SUBDIRS): Q :=
|
||||
$(CLEAN_FTL_SUBDIRS): clean_ftl_%:%
|
||||
$(_Q)cd $< && $(CLEAN_C)
|
||||
|
@ -13,5 +13,6 @@
|
||||
#include "spdk/crc32.h"
|
||||
|
||||
#include "ftl_core.h"
|
||||
#include "ftl_internal.h"
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT(ftl_core)
|
||||
|
@ -15,7 +15,9 @@
|
||||
#include "spdk/ftl.h"
|
||||
#include "spdk/bdev.h"
|
||||
#include "spdk/bdev_zone.h"
|
||||
#include "spdk/log.h"
|
||||
|
||||
#include "ftl_internal.h"
|
||||
#include "utils/ftl_log.h"
|
||||
|
||||
struct spdk_ftl_dev {
|
||||
/* Device instance */
|
||||
|
23
lib/ftl/ftl_internal.h
Normal file
23
lib/ftl/ftl_internal.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef FTL_INTERNAL_H
|
||||
#define FTL_INTERNAL_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/crc32.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/uuid.h"
|
||||
|
||||
/* Marks address as invalid */
|
||||
#define FTL_ADDR_INVALID ((ftl_addr)-1)
|
||||
|
||||
/*
|
||||
* This type represents address in the ftl address space. Values from 0 to based bdev size are
|
||||
* mapped directly to base device lbas. Values above that represent nv cache lbas.
|
||||
*/
|
||||
typedef uint64_t ftl_addr;
|
||||
|
||||
#endif /* FTL_INTERNAL_H */
|
11
lib/ftl/ftl_utils.h
Normal file
11
lib/ftl/ftl_utils.h
Normal file
@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef FTL_FTL_UTILS_H
|
||||
#define FTL_FTL_UTILS_H
|
||||
|
||||
#include "utils/ftl_defs.h"
|
||||
|
||||
#endif /* FTL_FTL_UTILS_H */
|
40
lib/ftl/utils/ftl_defs.h
Normal file
40
lib/ftl/utils/ftl_defs.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef FTL_DEFS_H
|
||||
#define FTL_DEFS_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#ifndef KiB
|
||||
#define KiB (1ULL << 10)
|
||||
#endif
|
||||
|
||||
#ifndef MiB
|
||||
#define MiB (1ULL << 20)
|
||||
#endif
|
||||
|
||||
#ifndef GiB
|
||||
#define GiB (1ULL << 30)
|
||||
#endif
|
||||
|
||||
#ifndef TiB
|
||||
#define TiB (1ULL << 40)
|
||||
#endif
|
||||
|
||||
#define ftl_abort() \
|
||||
do { \
|
||||
assert(false); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define ftl_bug(cond) \
|
||||
do { \
|
||||
if (spdk_unlikely((cond))) { \
|
||||
ftl_abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* FTL_DEFS_H */
|
35
lib/ftl/utils/ftl_log.h
Normal file
35
lib/ftl/utils/ftl_log.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef FTL_LOG_H
|
||||
#define FTL_LOG_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/log.h"
|
||||
|
||||
#define FTL_LOG_COMMON(type, dev, format, ...) \
|
||||
if ((dev) == NULL) \
|
||||
{ \
|
||||
spdk_log(SPDK_LOG_##type, __FILE__, __LINE__, __func__, "[FTL] "format, ## __VA_ARGS__); \
|
||||
} else { \
|
||||
spdk_log(SPDK_LOG_##type, __FILE__, __LINE__, __func__, "[FTL][%s] "format, (dev)->name, ## __VA_ARGS__); \
|
||||
} \
|
||||
|
||||
#define FTL_ERRLOG(dev, format, ...) \
|
||||
FTL_LOG_COMMON(ERROR, dev, format, ## __VA_ARGS__)
|
||||
|
||||
#define FTL_WARNLOG(dev, format, ...) \
|
||||
FTL_LOG_COMMON(WARN, dev, format, ## __VA_ARGS__)
|
||||
|
||||
#define FTL_NOTICELOG(dev, format, ...) \
|
||||
FTL_LOG_COMMON(NOTICE, dev, format, ## __VA_ARGS__)
|
||||
|
||||
#define FTL_INFOLOG(dev, format, ...) \
|
||||
FTL_LOG_COMMON(INFO, dev, format, ## __VA_ARGS__)
|
||||
|
||||
#define FTL_DEBUGLOG(dev, format, ...) \
|
||||
FTL_LOG_COMMON(DEBUG, dev, format, ## __VA_ARGS__)
|
||||
|
||||
#endif /* FTL_LOG_H */
|
Loading…
Reference in New Issue
Block a user