summaryrefslogtreecommitdiffstats
path: root/src/spdk/ocf/inc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/ocf/inc
parentInitial commit. (diff)
downloadceph-upstream/18.2.2.tar.xz
ceph-upstream/18.2.2.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/ocf/inc')
-rw-r--r--src/spdk/ocf/inc/cleaning/acp.h49
-rw-r--r--src/spdk/ocf/inc/cleaning/alru.h74
-rw-r--r--src/spdk/ocf/inc/ocf.h37
-rw-r--r--src/spdk/ocf/inc/ocf_cache.h240
-rw-r--r--src/spdk/ocf/inc/ocf_cfg.h36
-rw-r--r--src/spdk/ocf/inc/ocf_cleaner.h67
-rw-r--r--src/spdk/ocf/inc/ocf_core.h251
-rw-r--r--src/spdk/ocf/inc/ocf_ctx.h310
-rw-r--r--src/spdk/ocf/inc/ocf_def.h357
-rw-r--r--src/spdk/ocf/inc/ocf_err.h130
-rw-r--r--src/spdk/ocf/inc/ocf_io.h238
-rw-r--r--src/spdk/ocf/inc/ocf_io_class.h109
-rw-r--r--src/spdk/ocf/inc/ocf_logger.h44
-rw-r--r--src/spdk/ocf/inc/ocf_metadata.h143
-rw-r--r--src/spdk/ocf/inc/ocf_metadata_updater.h50
-rw-r--r--src/spdk/ocf/inc/ocf_mngt.h1107
-rw-r--r--src/spdk/ocf/inc/ocf_queue.h129
-rw-r--r--src/spdk/ocf/inc/ocf_stats.h239
-rw-r--r--src/spdk/ocf/inc/ocf_trace.h185
-rw-r--r--src/spdk/ocf/inc/ocf_types.h95
-rw-r--r--src/spdk/ocf/inc/ocf_volume.h338
-rw-r--r--src/spdk/ocf/inc/promotion/nhit.h23
22 files changed, 4251 insertions, 0 deletions
diff --git a/src/spdk/ocf/inc/cleaning/acp.h b/src/spdk/ocf/inc/cleaning/acp.h
new file mode 100644
index 000000000..9ca121a84
--- /dev/null
+++ b/src/spdk/ocf/inc/cleaning/acp.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+#ifndef __OCF_CLEANING_ACP_H__
+#define __OCF_CLEANING_ACP_H__
+
+/**
+ * @file
+ * @brief ACP cleaning policy API
+ */
+
+enum ocf_cleaning_acp_parameters {
+ ocf_acp_wake_up_time,
+ ocf_acp_flush_max_buffers,
+};
+
+/**
+ * @name ACP cleaning policy parameters
+ * @{
+ */
+
+/**
+ * ACP cleaning policy time between flushing cycles (in ms)
+ */
+
+/**< Wake up time minimum value */
+#define OCF_ACP_MIN_WAKE_UP 0
+/**< Wake up time maximum value */
+#define OCF_ACP_MAX_WAKE_UP 10000
+/**< Wake up time default value */
+#define OCF_ACP_DEFAULT_WAKE_UP 10
+
+/**
+ * ACP cleaning thread number of dirty cache lines to be flushed in one cycle
+ */
+
+/** Dirty cache lines to be flushed in one cycle minimum value */
+#define OCF_ACP_MIN_FLUSH_MAX_BUFFERS 1
+/** Dirty cache lines to be flushed in one cycle maximum value */
+#define OCF_ACP_MAX_FLUSH_MAX_BUFFERS 10000
+/** Dirty cache lines to be flushed in one cycle default value */
+#define OCF_ACP_DEFAULT_FLUSH_MAX_BUFFERS 128
+
+/**
+ * @}
+ */
+
+#endif /* __OCF_CLEANING_ACP_H__ */
diff --git a/src/spdk/ocf/inc/cleaning/alru.h b/src/spdk/ocf/inc/cleaning/alru.h
new file mode 100644
index 000000000..66548bbec
--- /dev/null
+++ b/src/spdk/ocf/inc/cleaning/alru.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+#ifndef __OCF_CLEANING_ALRU_H__
+#define __OCF_CLEANING_ALRU_H__
+
+/**
+ * @file
+ * @brief ALRU cleaning policy API
+ */
+
+enum ocf_cleaning_alru_parameters {
+ ocf_alru_wake_up_time,
+ ocf_alru_stale_buffer_time,
+ ocf_alru_flush_max_buffers,
+ ocf_alru_activity_threshold,
+};
+
+/**
+ * @name ALRU cleaning policy parameters
+ * @{
+ */
+
+/**
+ * ALRU cleaning thread wake up time
+ */
+
+/** Wake up time minimum value */
+#define OCF_ALRU_MIN_WAKE_UP 0
+/** Wake up time maximum value */
+#define OCF_ALRU_MAX_WAKE_UP 3600
+/** Wake up time default value */
+#define OCF_ALRU_DEFAULT_WAKE_UP 20
+
+/**
+ * ALRU cleaning thread staleness time
+ */
+
+/** Staleness time minimum value */
+#define OCF_ALRU_MIN_STALENESS_TIME 1
+/** Staleness time maximum value */
+#define OCF_ALRU_MAX_STALENESS_TIME 3600
+/** Staleness time default value*/
+#define OCF_ALRU_DEFAULT_STALENESS_TIME 120
+
+/**
+ * ALRU cleaning thread number of dirty cache lines to be flushed in one cycle
+ */
+
+/** Dirty cache lines to be flushed in one cycle minimum value */
+#define OCF_ALRU_MIN_FLUSH_MAX_BUFFERS 1
+/** Dirty cache lines to be flushed in one cycle maximum value */
+#define OCF_ALRU_MAX_FLUSH_MAX_BUFFERS 10000
+/** Dirty cache lines to be flushed in one cycle default value */
+#define OCF_ALRU_DEFAULT_FLUSH_MAX_BUFFERS 100
+
+/**
+ * ALRU cleaning thread cache idle time before flushing thread can start
+ */
+
+/** Idle time before flushing thread can start minimum value */
+#define OCF_ALRU_MIN_ACTIVITY_THRESHOLD 0
+/** Idle time before flushing thread can start maximum value */
+#define OCF_ALRU_MAX_ACTIVITY_THRESHOLD 1000000
+/** Idle time before flushing thread can start default value */
+#define OCF_ALRU_DEFAULT_ACTIVITY_THRESHOLD 10000
+
+/**
+ * @}
+ */
+
+
+#endif /* __OCF_CLEANING_ALRU_H__ */
diff --git a/src/spdk/ocf/inc/ocf.h b/src/spdk/ocf/inc/ocf.h
new file mode 100644
index 000000000..7b014119f
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_H__
+#define __OCF_H__
+
+/**
+ * @file
+ * @brief Main OCF header
+ * This file doesn't contain any functions or structures.
+ * It's simply collective include file to allow OCF user include
+ * everything at once.
+ */
+
+#include "ocf_def.h"
+#include "ocf_types.h"
+#include "ocf_io.h"
+#include "ocf_volume.h"
+#include "ocf_cache.h"
+#include "ocf_core.h"
+#include "ocf_queue.h"
+#include "ocf_cleaner.h"
+#include "cleaning/alru.h"
+#include "cleaning/acp.h"
+#include "promotion/nhit.h"
+#include "ocf_metadata.h"
+#include "ocf_metadata_updater.h"
+#include "ocf_io_class.h"
+#include "ocf_stats.h"
+#include "ocf_mngt.h"
+#include "ocf_ctx.h"
+#include "ocf_err.h"
+#include "ocf_trace.h"
+
+#endif /* __OCF_H__ */
diff --git a/src/spdk/ocf/inc/ocf_cache.h b/src/spdk/ocf/inc/ocf_cache.h
new file mode 100644
index 000000000..80860dc81
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_cache.h
@@ -0,0 +1,240 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+
+#ifndef __OCF_CACHE_H__
+#define __OCF_CACHE_H__
+
+/**
+ * @file
+ * @brief OCF cache API
+ */
+
+#include "ocf_volume.h"
+#include "ocf_ctx.h"
+#include "ocf_def.h"
+#include "ocf_stats.h"
+
+/**
+ * @brief Cache info: configuration, status
+ */
+struct ocf_cache_info {
+ bool attached;
+ /*!< True if caching cache is attached to cache */
+
+ uint8_t volume_type;
+ /*!< Cache volume type */
+
+ uint32_t size;
+ /*!< Actual cache size (in cache lines) */
+
+ /* Statistics of inactive cores */
+ struct {
+ struct ocf_stat occupancy;
+ /*!< Cache occupancy (in cache lines) */
+
+ struct ocf_stat clean;
+ /*!< Clean blocks within cache (in cache lines) */
+
+ struct ocf_stat dirty;
+ /*!< Dirty blocks within cache (in cache lines) */
+ } inactive;
+
+ uint32_t occupancy;
+ /*!< Actual cache occupancy (in cache lines) */
+
+ uint32_t dirty;
+ /*!< Dirty blocks within cache (in cache lines) */
+
+ uint32_t dirty_initial;
+ /*!< Dirty blocks within cache that where there when switching
+ * out of WB mode
+ */
+
+ uint32_t dirty_for;
+ /*!< How long there are dirty cache lines (in seconds) */
+
+ ocf_cache_mode_t cache_mode;
+ /*!< Current cache mode */
+
+ /* Statistics of fallback Pass Through */
+ struct {
+ int error_counter;
+ /*!< How many requests to cache failed because of IO error */
+
+ bool status;
+ /*!< Current cache mode is PT,
+ set as a result of reaching IO error threshold */
+ } fallback_pt;
+
+ uint8_t state;
+ /*!< Cache state (running/flushing/stopping etc...) */
+
+ ocf_eviction_t eviction_policy;
+ /*!< Eviction policy selected */
+
+ ocf_cleaning_t cleaning_policy;
+ /*!< Cleaning policy selected */
+
+ ocf_promotion_t promotion_policy;
+ /*!< Promotion policy selected */
+
+ ocf_cache_line_size_t cache_line_size;
+ /*!< Cache line size in KiB */
+
+ uint32_t flushed;
+ /*!< Number of block flushed in ongoing flush operation */
+
+ uint32_t core_count;
+ /*!< Number of core devices associated with this cache */
+
+ uint64_t metadata_footprint;
+ /*!< Metadata memory footprint (in bytes) */
+
+ uint32_t metadata_end_offset;
+ /*!< LBA offset where metadata ends (in 4KiB blocks) */
+};
+
+/**
+ * @brief Obtain volume from cache
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Volume, NULL if dettached.
+ */
+ocf_volume_t ocf_cache_get_volume(ocf_cache_t cache);
+
+/**
+ * @brief Get name of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Cache name
+ */
+const char *ocf_cache_get_name(ocf_cache_t cache);
+
+/**
+ * @brief Check is cache in incomplete state
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval 1 Cache is in incomplete state
+ * @retval 0 Cache is in complete state
+ */
+bool ocf_cache_is_incomplete(ocf_cache_t cache);
+
+/**
+ * @brief Check if caching device is attached
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval 1 Caching device is attached
+ * @retval 0 Caching device is detached
+ */
+bool ocf_cache_is_device_attached(ocf_cache_t cache);
+
+/**
+ * @brief Check if cache object is running
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval 1 Caching device is being stopped
+ * @retval 0 Caching device is being stopped
+ */
+bool ocf_cache_is_running(ocf_cache_t cache);
+
+/**
+ * @brief Get cache mode of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Cache mode
+ */
+ocf_cache_mode_t ocf_cache_get_mode(ocf_cache_t cache);
+
+/**
+ * @brief Get cache line size of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Cache line size
+ */
+ocf_cache_line_size_t ocf_cache_get_line_size(ocf_cache_t cache);
+
+/**
+ * @brief Convert bytes to cache lines
+ *
+ * @param[in] cache Cache object
+ * @param[in] bytes Number of bytes
+ *
+ * @retval Cache lines count
+ */
+uint64_t ocf_cache_bytes_2_lines(ocf_cache_t cache, uint64_t bytes);
+
+/**
+ * @brief Get core count of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Core count
+ */
+uint32_t ocf_cache_get_core_count(ocf_cache_t cache);
+
+/**
+ * @brief Get cache mode of given cache object
+ *
+ * @param[in] cache Cache object
+ * @param[out] info Cache info structure
+ *
+ * @retval 0 Success
+ * @retval Non-zero Fail
+ */
+int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info);
+
+/**
+ * @brief Get UUID of volume associated with cache
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Volume UUID, NULL if detached.
+ */
+const struct ocf_volume_uuid *ocf_cache_get_uuid(ocf_cache_t cache);
+
+/**
+ * @brief Get OCF context of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval OCF context
+ */
+ocf_ctx_t ocf_cache_get_ctx(ocf_cache_t cache);
+
+/**
+ * @brief Get volume type id of given cache object
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval volume type id, -1 if device detached
+ */
+uint8_t ocf_cache_get_type_id(ocf_cache_t cache);
+
+/**
+ * @brief Set cache private data
+ *
+ * @param[in] cache Cache object
+ * @param[in] priv Private data
+ */
+void ocf_cache_set_priv(ocf_cache_t cache, void *priv);
+
+/**
+ * @brief Get cache private data
+ *
+ * @param[in] cache Cache object
+ *
+ * @retval Private data
+ */
+void *ocf_cache_get_priv(ocf_cache_t cache);
+
+#endif /* __OCF_CACHE_H__ */
diff --git a/src/spdk/ocf/inc/ocf_cfg.h b/src/spdk/ocf/inc/ocf_cfg.h
new file mode 100644
index 000000000..266d6c968
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_cfg.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+
+#ifndef __OCF_CFG_H__
+#define __OCF_CFG_H__
+
+/**
+ * @file
+ * @brief OCF configuration file
+ */
+
+/**
+ * Configure maximum numbers of cores in cache instance
+ */
+#ifndef OCF_CONFIG_MAX_CORES
+#define OCF_CONFIG_MAX_CORES 4096
+#endif
+
+/** Maximum number of IO classes that can be configured */
+#ifndef OCF_CONFIG_MAX_IO_CLASSES
+#define OCF_CONFIG_MAX_IO_CLASSES 33
+#endif
+
+#if OCF_CONFIG_MAX_IO_CLASSES > 256
+#error "Limit of maximum number of IO classes exceeded"
+#endif
+
+/** Enabling debug statistics */
+#ifndef OCF_CONFIG_DEBUG_STATS
+#define OCF_CONFIG_DEBUG_STATS 0
+#endif
+
+#endif /* __OCF_CFG_H__ */
diff --git a/src/spdk/ocf/inc/ocf_cleaner.h b/src/spdk/ocf/inc/ocf_cleaner.h
new file mode 100644
index 000000000..43d6a30cc
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_cleaner.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef OCF_CLEANER_H_
+#define OCF_CLEANER_H_
+
+/**
+ * @file
+ * @brief OCF cleaner API for synchronization dirty data
+ *
+ */
+
+/**
+ * @brief OCF Cleaner completion
+ *
+ * @note Completion function for cleaner
+ *
+ * @param[in] cleaner Cleaner instance
+ * @param[in] interval Time to sleep before next cleaner iteration
+ */
+typedef void (*ocf_cleaner_end_t)(ocf_cleaner_t cleaner, uint32_t interval);
+
+/**
+ * @brief Set cleaner completion function
+ *
+ * @param[in] cleaner Cleaner instance
+ * @param[in] fn Completion function
+ */
+void ocf_cleaner_set_cmpl(ocf_cleaner_t cleaner, ocf_cleaner_end_t fn);
+
+/**
+ * @brief Run cleaner
+ *
+ * @param[in] c Cleaner instance to run
+ * @param[in] queue IO queue handle
+ */
+void ocf_cleaner_run(ocf_cleaner_t c, ocf_queue_t queue);
+
+/**
+ * @brief Set cleaner private data
+ *
+ * @param[in] c Cleaner handle
+ * @param[in] priv Private data
+ */
+void ocf_cleaner_set_priv(ocf_cleaner_t c, void *priv);
+
+/**
+ * @brief Get cleaner private data
+ *
+ * @param[in] c Cleaner handle
+ *
+ * @retval Cleaner private data
+ */
+void *ocf_cleaner_get_priv(ocf_cleaner_t c);
+
+/**
+ * @brief Get cache instance to which cleaner belongs
+ *
+ * @param[in] c Cleaner handle
+ *
+ * @retval Cache instance
+ */
+ocf_cache_t ocf_cleaner_get_cache(ocf_cleaner_t c);
+
+#endif
diff --git a/src/spdk/ocf/inc/ocf_core.h b/src/spdk/ocf/inc/ocf_core.h
new file mode 100644
index 000000000..f9e8f6714
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_core.h
@@ -0,0 +1,251 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+/**
+ * @file
+ * @brief OCF core API
+ */
+
+#ifndef __OCF_CORE_H__
+#define __OCF_CORE_H__
+
+#include "ocf_volume.h"
+#include "ocf_io.h"
+#include "ocf_mngt.h"
+
+struct ocf_core_info {
+ /** Core size in cache line size unit */
+ uint64_t core_size;
+
+ /** Core size in bytes unit */
+ uint64_t core_size_bytes;
+
+ /** Fields refers ongoing flush operation */
+ struct {
+ /** Number of blocks flushed in ongoing flush operation */
+ uint32_t flushed;
+
+ /** Number of blocks left to flush in ongoing flush operation */
+ uint32_t dirty;
+ };
+
+ /** How long core is dirty in seconds unit */
+ uint32_t dirty_for;
+
+ /** Sequential cutoff threshold (in bytes) */
+ uint32_t seq_cutoff_threshold;
+
+ /** Sequential cutoff policy */
+ ocf_seq_cutoff_policy seq_cutoff_policy;
+};
+
+/**
+ * @brief Get OCF core by name
+ *
+ * @param[in] cache OCF cache
+ * @param[in] name Core name
+ * @param[in] name_len Core name length
+ * @param[out] core OCF core handle
+ *
+ * @retval 0 Get cache successfully
+ * @retval -OCF_ERR_CORE_NOT_EXIST Core with given name doesn't exist
+ */
+int ocf_core_get_by_name(ocf_cache_t cache, const char *name, size_t name_len,
+ ocf_core_t *core);
+
+/**
+ * @brief Obtain cache object from core
+ *
+ * @param[in] core Core object
+ *
+ * @retval Cache object
+ */
+ocf_cache_t ocf_core_get_cache(ocf_core_t core);
+
+/**
+ * @brief Obtain volume associated with core
+ *
+ * @param[in] core Core object
+ *
+ * @retval Volume
+ */
+ocf_volume_t ocf_core_get_volume(ocf_core_t core);
+
+/**
+ * @brief Obtain volume of the core
+ *
+ * @param[in] core Core object
+ *
+ * @retval Front volume
+ */
+ocf_volume_t ocf_core_get_front_volume(ocf_core_t core);
+
+/**
+ * @brief Get UUID of volume associated with core
+ *
+ * @param[in] core Core object
+ *
+ * @retval Volume UUID
+ */
+static inline const struct ocf_volume_uuid *ocf_core_get_uuid(ocf_core_t core)
+{
+ return ocf_volume_get_uuid(ocf_core_get_volume(core));
+}
+
+/**
+ * @brief Get sequential cutoff threshold of given core object
+ *
+ * @param[in] core Core object
+ *
+ * @retval Sequential cutoff threshold [B]
+ */
+uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core);
+
+/**
+ * @brief Get sequential cutoff policy of given core object
+ *
+ * @param[in] core Core object
+ *
+ * @retval Sequential cutoff policy
+ */
+ocf_seq_cutoff_policy ocf_core_get_seq_cutoff_policy(ocf_core_t core);
+
+/**
+ * @brief Get name of given core object
+ *
+ * @param[in] core Core object
+ *
+ * @retval Core name
+ */
+const char *ocf_core_get_name(ocf_core_t core);
+
+/**
+ * @brief Get core state
+ *
+ * @param[in] core Core object
+ *
+ * @retval Core state
+ */
+ocf_core_state_t ocf_core_get_state(ocf_core_t core);
+
+/**
+ * @brief Allocate new ocf_io
+ *
+ * @param[in] core Core object
+ * @param[in] queue IO queue handle
+ * @param[in] addr OCF IO destination address
+ * @param[in] bytes OCF IO size in bytes
+ * @param[in] dir OCF IO direction
+ * @param[in] io_class OCF IO destination class
+ * @param[in] flags OCF IO flags
+ *
+ * @retval ocf_io object
+ */
+static inline struct ocf_io *ocf_core_new_io(ocf_core_t core, ocf_queue_t queue,
+ uint64_t addr, uint32_t bytes, uint32_t dir,
+ uint32_t io_class, uint64_t flags)
+{
+ ocf_volume_t volume = ocf_core_get_front_volume(core);
+
+ return ocf_volume_new_io(volume, queue, addr, bytes, dir,
+ io_class, flags);
+}
+
+/**
+ * @brief Submit ocf_io
+ *
+ * @param[in] io IO to be submitted
+ */
+static inline void ocf_core_submit_io(struct ocf_io *io)
+{
+ ocf_volume_submit_io(io);
+}
+
+/**
+ * @brief Fast path for submitting IO. If possible, request is processed
+ * immediately without adding to internal request queue
+ *
+ * @param[in] io IO to be submitted
+ *
+ * @retval 0 IO has been submitted successfully
+ * @retval Non-zero Fast submit failed. Try to submit IO with ocf_core_submit_io()
+ */
+int ocf_core_submit_io_fast(struct ocf_io *io);
+
+/**
+ * @brief Submit ocf_io with flush command
+ *
+ * @param[in] io IO to be submitted
+ */
+static inline void ocf_core_submit_flush(struct ocf_io *io)
+{
+ ocf_volume_submit_flush(io);
+}
+
+/**
+ * @brief Submit ocf_io with discard command
+ *
+ * @param[in] io IO to be submitted
+ */
+static inline void ocf_core_submit_discard(struct ocf_io *io)
+{
+ ocf_volume_submit_discard(io);
+}
+
+/**
+ * @brief Core visitor function type which is called back when iterating over
+ * cores.
+ *
+ * @param[in] core Core which is currently iterated (visited)
+ * @param[in] cntx Visitor context
+ *
+ * @retval 0 continue visiting cores
+ * @retval Non-zero stop iterating and return result
+ */
+typedef int (*ocf_core_visitor_t)(ocf_core_t core, void *cntx);
+
+/**
+ * @brief Run visitor function for each core of given cache
+ *
+ * @param[in] cache OCF cache instance
+ * @param[in] visitor Visitor function
+ * @param[in] cntx Visitor context
+ * @param[in] only_opened Visit only opened cores
+ *
+ * @retval 0 Success
+ * @retval Non-zero Fail
+ */
+int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
+ bool only_opened);
+
+/**
+ * @brief Get info of given core object
+ *
+ * @param[in] core Core object
+ * @param[out] info Core info structure
+ *
+ * @retval 0 Success
+ * @retval Non-zero Fail
+ */
+int ocf_core_get_info(ocf_core_t core, struct ocf_core_info *info);
+
+/**
+ * @brief Set core private data
+ *
+ * @param[in] core Core object
+ * @param[in] priv Private data
+ */
+void ocf_core_set_priv(ocf_core_t core, void *priv);
+
+/**
+ * @brief Get core private data
+ *
+ * @param[in] core Core object
+ *
+ * @retval Private data
+ */
+void *ocf_core_get_priv(ocf_core_t core);
+
+#endif /* __OCF_CORE_H__ */
diff --git a/src/spdk/ocf/inc/ocf_ctx.h b/src/spdk/ocf/inc/ocf_ctx.h
new file mode 100644
index 000000000..b12cc3cba
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_ctx.h
@@ -0,0 +1,310 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_CTX_H__
+#define __OCF_CTX_H__
+
+/**
+ * @file
+ * @brief OCF library context API
+ */
+
+#include "ocf_volume.h"
+#include "ocf_logger.h"
+
+/**
+ * @brief Seeking start position in environment data buffer
+ */
+typedef enum {
+ ctx_data_seek_begin,
+ /*!< Seeking from the beginning of environment data buffer */
+ ctx_data_seek_current,
+ /*!< Seeking from current position in environment data buffer */
+} ctx_data_seek_t;
+
+/**
+ * @brief Context data representation ops
+ */
+struct ocf_data_ops {
+ /**
+ * @brief Allocate contest data buffer
+ *
+ * @param[in] pages The size of data buffer in pages
+ *
+ * @return Context data buffer
+ */
+ ctx_data_t *(*alloc)(uint32_t pages);
+
+ /**
+ * @brief Free context data buffer
+ *
+ * @param[in] data Contex data buffer which shall be freed
+ */
+ void (*free)(ctx_data_t *data);
+
+ /**
+ * @brief Lock context data buffer to disable swap-out
+ *
+ * @param[in] data Contex data buffer which shall be locked
+ *
+ * @retval 0 Memory locked successfully
+ * @retval Non-zero Memory locking failure
+ */
+ int (*mlock)(ctx_data_t *data);
+
+ /**
+ * @brief Unlock context data buffer
+ *
+ * @param[in] data Contex data buffer which shall be unlocked
+ */
+ void (*munlock)(ctx_data_t *data);
+
+ /**
+ * @brief Read from environment data buffer into raw data buffer
+ *
+ * @param[in,out] dst Destination raw memory buffer
+ * @param[in] src Source context data buffer
+ * @param[in] size Number of bytes to be read
+ *
+ * @return Number of read bytes
+ */
+ uint32_t (*read)(void *dst, ctx_data_t *src, uint32_t size);
+
+ /**
+ * @brief Write raw data buffer into context data buffer
+ *
+ * @param[in,out] dst Destination context data buffer
+ * @param[in] src Source raw memory buffer
+ * @param[in] size Number of bytes to be written
+ *
+ * @return Number of written bytes
+ */
+ uint32_t (*write)(ctx_data_t *dst, const void *src, uint32_t size);
+
+ /**
+ * @brief Zero context data buffer
+ *
+ * @param[in,out] dst Destination context data buffer to be zeroed
+ * @param[in] size Number of bytes to be zeroed
+ *
+ * @return Number of zeroed bytes
+ */
+ uint32_t (*zero)(ctx_data_t *dst, uint32_t size);
+
+ /**
+ * @brief Seek read/write head in context data buffer for specified
+ * offset
+ *
+ * @param[in,out] dst Destination context data buffer to be seek
+ * @param[in] seek Seek beginning offset
+ * @param[in] size Number of bytes to be seek
+ *
+ * @return Number of seek bytes
+ */
+ uint32_t (*seek)(ctx_data_t *dst, ctx_data_seek_t seek, uint32_t size);
+
+ /**
+ * @brief Copy context data buffer content
+ *
+ * @param[in,out] dst Destination context data buffer
+ * @param[in] src Source context data buffer
+ * @param[in] to Starting offset in destination buffer
+ * @param[in] from Starting offset in source buffer
+ * @param[in] bytes Number of bytes to be copied
+ *
+ * @return Number of bytes copied
+ */
+ uint64_t (*copy)(ctx_data_t *dst, ctx_data_t *src,
+ uint64_t to, uint64_t from, uint64_t bytes);
+
+ /**
+ * @brief Erase content of data buffer
+ *
+ * @param[in] dst Contex data buffer which shall be erased
+ */
+ void (*secure_erase)(ctx_data_t *dst);
+};
+
+/**
+ * @brief Cleaner operations
+ */
+struct ocf_cleaner_ops {
+ /**
+ * @brief Initialize cleaner.
+ *
+ * This function should create worker, thread, timer or any other
+ * mechanism responsible for calling cleaner routine.
+ *
+ * @param[in] c Descriptor of cleaner to be initialized
+ *
+ * @retval 0 Cleaner has been initializaed successfully
+ * @retval Non-zero Cleaner initialization failure
+ */
+ int (*init)(ocf_cleaner_t c);
+
+ /**
+ * @brief Kick cleaner thread.
+ *
+ * @param[in] c Descriptor of cleaner to be kicked.
+ */
+ void (*kick)(ocf_cleaner_t c);
+
+ /**
+ * @brief Stop cleaner
+ *
+ * @param[in] c Descriptor of cleaner beeing stopped
+ */
+ void (*stop)(ocf_cleaner_t c);
+};
+
+/**
+ * @brief Metadata updater operations
+ */
+struct ocf_metadata_updater_ops {
+ /**
+ * @brief Initialize metadata updater.
+ *
+ * This function should create worker, thread, timer or any other
+ * mechanism responsible for calling metadata updater routine.
+ *
+ * @param[in] mu Handle to metadata updater to be initialized
+ *
+ * @retval 0 Metadata updater has been initializaed successfully
+ * @retval Non-zero I/O queue initialization failure
+ */
+ int (*init)(ocf_metadata_updater_t mu);
+
+ /**
+ * @brief Kick metadata updater processing
+ *
+ * This function should inform worker, thread or any other mechanism,
+ * that there are new metadata requests to be processed.
+ *
+ * @param[in] mu Metadata updater to be kicked
+ */
+ void (*kick)(ocf_metadata_updater_t mu);
+
+ /**
+ * @brief Stop metadata updater
+ *
+ * @param[in] mu Metadata updater beeing stopped
+ */
+ void (*stop)(ocf_metadata_updater_t mu);
+};
+
+/**
+ * @brief OCF context specific operation
+ */
+struct ocf_ctx_ops {
+ /* Context data operations */
+ struct ocf_data_ops data;
+
+ /* Cleaner operations */
+ struct ocf_cleaner_ops cleaner;
+
+ /* Metadata updater operations */
+ struct ocf_metadata_updater_ops metadata_updater;
+
+ /* Logger operations */
+ struct ocf_logger_ops logger;
+};
+
+struct ocf_ctx_config {
+ /* Context name */
+ const char *name;
+
+ /* Context operations */
+ const struct ocf_ctx_ops ops;
+
+ /* Context logger priv */
+ void *logger_priv;
+};
+
+/**
+ * @brief Register volume interface
+ *
+ * @note Type of volume operations is unique and cannot be repeated.
+ *
+ * @param[in] ctx OCF context
+ * @param[in] properties Reference to volume properties
+ * @param[in] type_id Type id of volume operations
+ *
+ * @retval 0 Volume operations registered successfully
+ * @retval Non-zero Volume registration failure
+ */
+int ocf_ctx_register_volume_type(ocf_ctx_t ctx, uint8_t type_id,
+ const struct ocf_volume_properties *properties);
+
+/**
+ * @brief Unregister volume interface
+ *
+ * @param[in] ctx OCF context
+ * @param[in] type_id Type id of volume operations
+ */
+void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id);
+
+/**
+ * @brief Get volume type operations by type id
+ *
+ * @param[in] ctx OCF context
+ * @param[in] type_id Type id of volume operations which were registered
+ *
+ * @return Volume type
+ * @retval NULL When volume operations were not registered
+ * for requested type
+ */
+ocf_volume_type_t ocf_ctx_get_volume_type(ocf_ctx_t ctx, uint8_t type_id);
+
+/**
+ * @brief Get volume type id by type
+ *
+ * @param[in] ctx OCF context
+ * @param[in] type Type of volume operations which were registered
+ *
+ * @return Volume type id
+ * @retval -1 When volume operations were not registered
+ * for requested type
+ */
+int ocf_ctx_get_volume_type_id(ocf_ctx_t ctx, ocf_volume_type_t type);
+
+/**
+ * @brief Create volume of given type
+ *
+ * @param[in] ctx handle to object designating ocf context
+ * @param[out] volume volume handle
+ * @param[in] uuid OCF volume UUID
+ * @param[in] type_id cache/core volume type id
+ *
+ * @return Zero when success, othewise en error
+ */
+
+int ocf_ctx_volume_create(ocf_ctx_t ctx, ocf_volume_t *volume,
+ struct ocf_volume_uuid *uuid, uint8_t type_id);
+
+/**
+ * @brief Create and initialize OCF context
+ *
+ * @param[out] ctx OCF context
+ * @param[in] ops OCF context operations
+ *
+ * @return Zero when success, otherwise an error
+ */
+int ocf_ctx_create(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg);
+
+/**
+ * @brief Increase reference counter of ctx
+ *
+ * @param[in] ctx OCF context
+ */
+void ocf_ctx_get(ocf_ctx_t ctx);
+
+/**
+ * @brief Decrease reference counter of ctx
+ *
+ * @param[in] ctx OCF context
+ */
+void ocf_ctx_put(ocf_ctx_t ctx);
+
+#endif /* __OCF_CTX_H__ */
diff --git a/src/spdk/ocf/inc/ocf_def.h b/src/spdk/ocf/inc/ocf_def.h
new file mode 100644
index 000000000..bdbe21105
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_def.h
@@ -0,0 +1,357 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+
+#ifndef __OCF_DEF_H__
+#define __OCF_DEF_H__
+
+#include "ocf_cfg.h"
+/**
+ * @file
+ * @brief OCF definitions
+ */
+
+/**
+ * @name OCF cache definitions
+ */
+/**
+ * Minimum value of a valid cache ID
+ */
+#define OCF_CACHE_ID_MIN 1
+/**
+ * Maximum value of a valid cache ID
+ */
+#define OCF_CACHE_ID_MAX 16384
+/**
+ * Invalid value of cache id
+ */
+#define OCF_CACHE_ID_INVALID 0
+/**
+ * Minimum cache size in bytes
+ */
+#define OCF_CACHE_SIZE_MIN (20 * MiB)
+/**
+ * Size of cache name
+ */
+#define OCF_CACHE_NAME_SIZE 32
+/**
+ * Value to turn off fallback pass through
+ */
+#define OCF_CACHE_FALLBACK_PT_INACTIVE 0
+/**
+ * Minimum value of io error threshold
+ */
+#define OCF_CACHE_FALLBACK_PT_MIN_ERROR_THRESHOLD \
+ OCF_CACHE_FALLBACK_PT_INACTIVE
+/**
+ * Maximum value of io error threshold
+ */
+#define OCF_CACHE_FALLBACK_PT_MAX_ERROR_THRESHOLD 1000000
+/**
+ * @}
+ */
+
+/**
+ * @name OCF cores definitions
+ */
+/**
+ * Maximum numbers of cores per cache instance
+ */
+#define OCF_CORE_MAX OCF_CONFIG_MAX_CORES
+/**
+ * Minimum value of a valid core ID
+ */
+#define OCF_CORE_ID_MIN 0
+/**
+ * Maximum value of a valid core ID
+ */
+#define OCF_CORE_ID_MAX (OCF_CORE_MAX - 1)
+/**
+ * Invalid value of core id
+ */
+#define OCF_CORE_ID_INVALID OCF_CORE_MAX
+/**
+ * Size of core name
+ */
+#define OCF_CORE_NAME_SIZE 32
+/**
+ * Minimum value of valid core sequence number
+ */
+#define OCF_SEQ_NO_MIN 1
+/**
+ * Maximum value of a valid core sequence number
+ */
+#define OCF_SEQ_NO_MAX (65535UL)
+/*
+ * Invalid value of core sequence number
+ */
+#define OCF_SEQ_NO_INVALID 0
+/**
+ * @}
+ */
+
+/**
+ * @name Miscellaneous defines
+ * @{
+ */
+#define KiB (1ULL << 10)
+#define MiB (1ULL << 20)
+#define GiB (1ULL << 30)
+
+#if OCF_CONFIG_DEBUG_STATS == 1
+/** Macro which indicates that extended debug statistics shall be on*/
+#define OCF_DEBUG_STATS
+#endif
+/**
+ * @}
+ */
+
+/**
+ * This Enumerator describes OCF cache instance state
+ */
+typedef enum {
+ ocf_cache_state_running = 0, //!< ocf_cache_state_running
+ /*!< OCF is currently running */
+
+ ocf_cache_state_stopping = 1, //!< ocf_cache_state_stopping
+ /*!< OCF cache instance is stopping */
+
+ ocf_cache_state_initializing = 2, //!< ocf_cache_state_initializing
+ /*!< OCF cache instance during initialization */
+
+ ocf_cache_state_incomplete = 3, //!< ocf_cache_state_incomplete
+ /*!< OCF cache has at least one inactive core */
+
+ ocf_cache_state_max //!< ocf_cache_state_max
+ /*!< Stopper of cache state enumerator */
+} ocf_cache_state_t;
+
+/**
+ * This Enumerator describes OCF core instance state
+ */
+typedef enum {
+ ocf_core_state_active = 0,
+ /*!< Core is active */
+
+ ocf_core_state_inactive,
+ /*!< Core is inactive (not attached) */
+
+ ocf_core_state_max,
+ /*!< Stopper of core state enumerator */
+} ocf_core_state_t;
+
+
+/**
+ * OCF supported cache modes
+ */
+typedef enum {
+ ocf_cache_mode_wt = 0,
+ /*!< Write-through cache mode */
+
+ ocf_cache_mode_wb,
+ /*!< Write-back cache mode */
+
+ ocf_cache_mode_wa,
+ /*!< Write-around cache mode */
+
+ ocf_cache_mode_pt,
+ /*!< Pass-through cache mode */
+
+ ocf_cache_mode_wi,
+ /*!< Write invalidate cache mode */
+
+ ocf_cache_mode_wo,
+ /*!< Write-only cache mode */
+
+ ocf_cache_mode_max,
+ /*!< Stopper of cache mode enumerator */
+
+ ocf_cache_mode_default = ocf_cache_mode_wt,
+ /*!< Default cache mode */
+
+ ocf_cache_mode_none = -1,
+ /*!< Current cache mode of given cache instance */
+} ocf_cache_mode_t;
+
+typedef enum {
+ ocf_seq_cutoff_policy_always = 0,
+ /*!< Sequential cutoff always on */
+
+ ocf_seq_cutoff_policy_full,
+ /*!< Sequential cutoff when occupancy is 100% */
+
+ ocf_seq_cutoff_policy_never,
+ /*!< Sequential cutoff disabled */
+
+ ocf_seq_cutoff_policy_max,
+ /*!< Stopper of sequential cutoff policy enumerator */
+
+ ocf_seq_cutoff_policy_default = ocf_seq_cutoff_policy_full,
+ /*!< Default sequential cutoff policy*/
+} ocf_seq_cutoff_policy;
+
+/**
+ * OCF supported eviction policy types
+ */
+typedef enum {
+ ocf_eviction_lru = 0,
+ /*!< Last recently used eviction policy */
+
+ ocf_eviction_max,
+ /*!< Stopper of enumerator */
+
+ ocf_eviction_default = ocf_eviction_lru,
+ /*!< Default eviction policy */
+} ocf_eviction_t;
+
+/**
+ * OCF supported promotion policy types
+ */
+typedef enum {
+ ocf_promotion_always = 0,
+ /*!< No promotion policy. Cache inserts are not filtered */
+
+ ocf_promotion_nhit,
+ /*!< Line can be inserted after N requests for it */
+
+ ocf_promotion_max,
+ /*!< Stopper of enumerator */
+
+ ocf_promotion_default = ocf_promotion_always,
+ /*!< Default promotion policy */
+} ocf_promotion_t;
+
+/**
+ * OCF supported Write-Back cleaning policies type
+ */
+typedef enum {
+ ocf_cleaning_nop = 0,
+ /*!< Cleaning won't happen in background. Only on eviction or
+ * during cache stop
+ */
+
+ ocf_cleaning_alru,
+ /*!< Approximately recently used. Cleaning thread in the
+ * background enabled which cleans dirty data during IO
+ * inactivity.
+ */
+
+ ocf_cleaning_acp,
+ /*!< Cleaning algorithm attempts to reduce core device seek
+ * distance. Cleaning thread runs concurrently with I/O.
+ */
+
+ ocf_cleaning_max,
+ /*!< Stopper of enumerator */
+
+ ocf_cleaning_default = ocf_cleaning_alru,
+ /*!< Default cleaning policy type */
+} ocf_cleaning_t;
+
+/**
+ * OCF supported cache line sizes in bytes
+ */
+typedef enum {
+ ocf_cache_line_size_none = 0,
+ /*!< None */
+
+ ocf_cache_line_size_4 = 4 * KiB,
+ /*!< 4 kiB */
+
+ ocf_cache_line_size_8 = 8 * KiB,
+ /*!< 8 kiB */
+
+ ocf_cache_line_size_16 = 16 * KiB,
+ /*!< 16 kiB */
+
+ ocf_cache_line_size_32 = 32 * KiB,
+ /*!< 32 kiB */
+
+ ocf_cache_line_size_64 = 64 * KiB,
+ /*!< 64 kiB */
+
+ ocf_cache_line_size_default = ocf_cache_line_size_4,
+ /*!< Default cache line size */
+
+ ocf_cache_line_size_min = ocf_cache_line_size_4,
+ /*!< Minimum cache line size */
+
+ ocf_cache_line_size_max = ocf_cache_line_size_64,
+ /*!< Maximal cache line size */
+
+ ocf_cache_line_size_inf = ~0ULL,
+ /*!< Force enum to be 64-bit */
+} ocf_cache_line_size_t;
+
+/**
+ * Metadata layout
+ */
+typedef enum {
+ ocf_metadata_layout_striping = 0,
+ ocf_metadata_layout_seq = 1,
+ ocf_metadata_layout_max,
+ ocf_metadata_layout_default = ocf_metadata_layout_striping
+} ocf_metadata_layout_t;
+
+/**
+ * @name OCF IO class definitions
+ */
+/**
+ * Maximum numbers of IO classes per cache instance
+ */
+#define OCF_IO_CLASS_MAX OCF_CONFIG_MAX_IO_CLASSES
+/**
+ * Minimum value of a valid IO class ID
+ */
+#define OCF_IO_CLASS_ID_MIN 0
+/**
+ * Maximum value of a valid IO class ID
+ */
+#define OCF_IO_CLASS_ID_MAX (OCF_IO_CLASS_MAX - 1)
+/**
+ * Invalid value of IO class id
+ */
+#define OCF_IO_CLASS_INVALID OCF_IO_CLASS_MAX
+
+/** Maximum size of the IO class name */
+#define OCF_IO_CLASS_NAME_MAX 1024
+
+/** IO class priority which indicates pinning */
+#define OCF_IO_CLASS_PRIO_PINNED -1
+
+/** The highest IO class priority */
+#define OCF_IO_CLASS_PRIO_HIGHEST 0
+
+/** The lowest IO class priority */
+#define OCF_IO_CLASS_PRIO_LOWEST 255
+
+/** Default IO class priority */
+#define OCF_IO_CLASS_PRIO_DEFAULT OCF_IO_CLASS_PRIO_LOWEST
+/**
+ * @}
+ */
+
+/**
+ * @name I/O operations
+ * @{
+ */
+#define OCF_READ 0
+#define OCF_WRITE 1
+/**
+ * @}
+ */
+
+/**
+ * @name OCF cleaner definitions
+ * @{
+ */
+#define OCF_CLEANER_DISABLE ~0U
+/**
+ * @}
+ */
+
+#define MAX_TRIM_RQ_SIZE (512 * KiB)
+
+#endif /* __OCF_DEF_H__ */
diff --git a/src/spdk/ocf/inc/ocf_err.h b/src/spdk/ocf/inc/ocf_err.h
new file mode 100644
index 000000000..e4f71f2a3
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_err.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_ERR_H__
+#define __OCF_ERR_H__
+
+/**
+ * @file
+ * @brief OCF error codes definitions
+ */
+
+/**
+ * @brief OCF error enumerator
+ */
+typedef enum {
+ /** Invalid input parameter value */
+ OCF_ERR_INVAL = 1000000,
+
+ /** Try again */
+ OCF_ERR_AGAIN,
+
+ /** Operation interrupted */
+ OCF_ERR_INTR,
+
+ /** Operation not supported */
+ OCF_ERR_NOT_SUPP,
+
+ /** Out of memory */
+ OCF_ERR_NO_MEM,
+
+ /** Lock not acquired */
+ OCF_ERR_NO_LOCK,
+
+ /** Metadata version mismatch */
+ OCF_ERR_METADATA_VER,
+
+ /** No metadata found on device */
+ OCF_ERR_NO_METADATA,
+
+ /** Cache metadata found on device */
+ OCF_ERR_METADATA_FOUND,
+
+ /** Invalid volume type */
+ OCF_ERR_INVAL_VOLUME_TYPE,
+
+ /** Unknown error occurred */
+ OCF_ERR_UNKNOWN,
+
+ /** To many caches */
+ OCF_ERR_TOO_MANY_CACHES,
+
+ /** Not enough RAM to start cache */
+ OCF_ERR_NO_FREE_RAM,
+
+ /** Start cache failure */
+ OCF_ERR_START_CACHE_FAIL,
+
+ /** Cache ID/name does not exist */
+ OCF_ERR_CACHE_NOT_EXIST,
+
+ /** Core ID/name does not exist */
+ OCF_ERR_CORE_NOT_EXIST,
+
+ /** Cache ID/name already exists */
+ OCF_ERR_CACHE_EXIST,
+
+ /** Core ID/name already exists */
+ OCF_ERR_CORE_EXIST,
+
+ /** Too many core devices in cache */
+ OCF_ERR_TOO_MANY_CORES,
+
+ /** Core device not available */
+ OCF_ERR_CORE_NOT_AVAIL,
+
+ /** Cannot open device exclusively*/
+ OCF_ERR_NOT_OPEN_EXC,
+
+ /** Cache device not available */
+ OCF_ERR_CACHE_NOT_AVAIL,
+
+ /** IO Class does not exist */
+ OCF_ERR_IO_CLASS_NOT_EXIST,
+
+ /** IO Error */
+ OCF_ERR_IO,
+
+ /** Error while writing to cache device */
+ OCF_ERR_WRITE_CACHE,
+
+ /** Error while writing to core device */
+ OCF_ERR_WRITE_CORE,
+
+ /*!< Dirty shutdown */
+ OCF_ERR_DIRTY_SHUTDOWN,
+
+ /** Cache contains dirty data */
+ OCF_ERR_DIRTY_EXISTS,
+
+ /** Flushing of core interrupted */
+ OCF_ERR_FLUSHING_INTERRUPTED,
+
+ /** Another flushing operation in progress */
+ OCF_ERR_FLUSH_IN_PROGRESS,
+
+ /** Adding core to core pool failed */
+ OCF_ERR_CANNOT_ADD_CORE_TO_POOL,
+
+ /** Cache is in incomplete state */
+ OCF_ERR_CACHE_IN_INCOMPLETE_STATE,
+
+ /** Core device is in inactive state */
+ OCF_ERR_CORE_IN_INACTIVE_STATE,
+
+ /** Invalid cache mode */
+ OCF_ERR_INVALID_CACHE_MODE,
+
+ /** Invalid cache line size */
+ OCF_ERR_INVALID_CACHE_LINE_SIZE,
+
+ /** Invalid cache name loaded */
+ OCF_ERR_CACHE_NAME_MISMATCH,
+
+ /** Device does not meet requirements */
+ OCF_ERR_INVAL_CACHE_DEV,
+} ocf_error_t;
+
+#endif /* __OCF_ERR_H__ */
diff --git a/src/spdk/ocf/inc/ocf_io.h b/src/spdk/ocf/inc/ocf_io.h
new file mode 100644
index 000000000..f268320b8
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_io.h
@@ -0,0 +1,238 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+
+#ifndef __OCF_IO_H__
+#define __OCF_IO_H__
+
+#include "ocf_types.h"
+
+/**
+ * @file
+ * @brief OCF IO definitions
+ */
+
+struct ocf_io;
+
+/**
+ * @brief OCF IO start
+ *
+ * @note OCF IO start notification callback
+ *
+ * @param[in] io OCF IO being started
+ */
+typedef void (*ocf_start_io_t)(struct ocf_io *io);
+
+/**
+ * @brief OCF IO handle
+ *
+ * @note OCF IO handle callback
+ *
+ * @param[in] io OCF IO to handle
+ */
+typedef void (*ocf_handle_io_t)(struct ocf_io *io, void *opaque);
+
+/**
+ * @brief OCF IO completion
+ *
+ * @note Completion function for OCF IO
+ *
+ * @param[in] io OCF IO being completed
+ * @param[in] error Completion status code
+ */
+typedef void (*ocf_end_io_t)(struct ocf_io *io, int error);
+
+/**
+ * @brief OCF IO main structure
+ */
+struct ocf_io {
+ /**
+ * @brief OCF IO destination address
+ */
+ uint64_t addr;
+
+ /**
+ * @brief OCF IO flags
+ */
+ uint64_t flags;
+
+ /**
+ * @brief OCF IO size in bytes
+ */
+ uint32_t bytes;
+
+ /**
+ * @brief OCF IO destination class
+ */
+ uint32_t io_class;
+
+ /**
+ * @brief OCF IO direction
+ */
+ uint32_t dir;
+
+ /**
+ * @brief Queue handle
+ */
+ ocf_queue_t io_queue;
+
+ /**
+ * @brief OCF IO start function
+ */
+ ocf_start_io_t start;
+
+ /**
+ * @brief OCF IO handle function
+ */
+ ocf_handle_io_t handle;
+
+ /**
+ * @brief OCF IO completion function
+ */
+ ocf_end_io_t end;
+
+ /**
+ * @brief OCF IO private 1
+ */
+ void *priv1;
+
+ /**
+ * @brief OCF IO private 2
+ */
+ void *priv2;
+};
+
+/**
+ * @brief OCF IO operations set structure
+ */
+struct ocf_io_ops {
+ /**
+ * @brief Set up data vector in OCF IO
+ *
+ * @param[in] io OCF IO to set up
+ * @param[in] data Source context data
+ * @param[in] offset Data offset in source context data
+ *
+ * @retval 0 Data set up successfully
+ * @retval Non-zero Data set up failure
+ */
+ int (*set_data)(struct ocf_io *io, ctx_data_t *data,
+ uint32_t offset);
+
+ /**
+ * @brief Get context data from OCF IO
+ *
+ * @param[in] io OCF IO to get data
+ *
+ * @return Data vector from IO
+ */
+ ctx_data_t *(*get_data)(struct ocf_io *io);
+};
+
+/**
+ * @brief Get IO private context structure
+ *
+ * @param[in] io OCF IO
+ *
+ * @return IO private context structure
+ */
+void *ocf_io_get_priv(struct ocf_io *io);
+
+/**
+ * @brief Increase reference counter in OCF IO
+ *
+ * @note Wrapper for get IO operation
+ *
+ * @param[in] io OCF IO
+ */
+void ocf_io_get(struct ocf_io *io);
+
+/**
+ * @brief Decrease reference counter in OCF IO
+ *
+ * @note If IO don't have any reference - deallocate it
+ *
+ * @param[in] io OCF IO
+ */
+void ocf_io_put(struct ocf_io *io);
+
+/**
+ * @brief Set OCF IO completion function
+ *
+ * @param[in] io OCF IO
+ * @param[in] context Context for completion function
+ * @param[in] fn Completion function
+ */
+static inline void ocf_io_set_cmpl(struct ocf_io *io, void *context,
+ void *context2, ocf_end_io_t fn)
+{
+ io->priv1 = context;
+ io->priv2 = context2;
+ io->end = fn;
+}
+
+/**
+ * @brief Set OCF IO start function
+ *
+ * @param[in] io OCF IO
+ * @param[in] fn Start callback function
+ */
+static inline void ocf_io_set_start(struct ocf_io *io, ocf_start_io_t fn)
+{
+ io->start = fn;
+}
+
+/**
+ * @brief Set OCF IO handle function
+ *
+ * @param[in] io OCF IO
+ * @param[in] fn Handle callback function
+ */
+static inline void ocf_io_set_handle(struct ocf_io *io, ocf_handle_io_t fn)
+{
+ io->handle = fn;
+}
+
+/**
+ * @brief Set up data vector in OCF IO
+ *
+ * @note Wrapper for set up data vector function
+ *
+ * @param[in] io OCF IO to set up
+ * @param[in] data Source data vector
+ * @param[in] offset Data offset in source data vector
+ *
+ * @retval 0 Data set up successfully
+ * @retval Non-zero Data set up failure
+ */
+int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data, uint32_t offset);
+
+/**
+ * @brief Get data vector from OCF IO
+ *
+ * @note Wrapper for get data vector function
+ *
+ * @param[in] io OCF IO to get data
+ *
+ * @return Data vector from IO
+ */
+ctx_data_t *ocf_io_get_data(struct ocf_io *io);
+
+/**
+ * @brief Handle IO in cache engine
+ *
+ * @param[in] io OCF IO to be handled
+ * @param[in] opaque OCF opaque
+ */
+void ocf_io_handle(struct ocf_io *io, void *opaque);
+
+/**
+ * @brief Get volume associated with io
+ *
+ * @param[in] io OCF IO to be handled
+ */
+ocf_volume_t ocf_io_get_volume(struct ocf_io *io);
+
+#endif /* __OCF_IO_H__ */
diff --git a/src/spdk/ocf/inc/ocf_io_class.h b/src/spdk/ocf/inc/ocf_io_class.h
new file mode 100644
index 000000000..caab0db02
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_io_class.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+/**
+ * @file
+ * @brief IO class API
+ *
+ * File contains structures and methods for handling IO Class
+ * differentiation features
+ */
+
+#ifndef __OCF_IO_CLASS_H__
+#define __OCF_IO_CLASS_H__
+
+/**
+ * @brief OCF IO class information
+ */
+struct ocf_io_class_info {
+ char name[OCF_IO_CLASS_NAME_MAX];
+ /*!< The name of the IO class */
+
+ ocf_cache_mode_t cache_mode;
+ /*!< Cache mode of the IO class */
+
+ int16_t priority;
+ /*!< IO class priority */
+
+ uint32_t curr_size;
+ /*!< Current size of the IO class - number of cache lines which
+ * were assigned into this IO class
+ */
+
+ uint32_t min_size;
+ /*!< Minimum number of cache lines that were guaranteed
+ * for specified IO class. If current size reach minimum size
+ * that no more eviction takes place
+ */
+
+ uint32_t max_size;
+ /*!< Maximum number of cache lines that might be assigned into
+ * this IO class. If current size reach maximum size no more
+ * allocation for this IO class takes place
+ */
+
+ uint8_t eviction_policy_type;
+ /*!< The type of eviction policy for given IO class */
+
+ ocf_cleaning_t cleaning_policy_type;
+ /*!< The type of cleaning policy for given IO class */
+};
+
+/**
+ * @brief retrieve io class info
+ *
+ * function meant to retrieve information pertaining to particular IO class,
+ * specifically to fill ocf_io_class_info structure based on input parameters.
+ *
+ * @param[in] cache cache handle, to which specified request pertains.
+ * @param[in] io_class id of an io class which shall be retreived.
+ * @param[out] info io class info structures to be filled as a
+ * result of this function call.
+ *
+ * @return function returns 0 upon successful completion; appropriate error
+ * code is returned otherwise
+ */
+int ocf_cache_io_class_get_info(ocf_cache_t cache, uint32_t io_class,
+ struct ocf_io_class_info *info);
+
+/**
+ * @brief helper function for ocf_io_class_visit
+ *
+ * This function is called back from ocf_io_class_visit for each valid
+ * configured io class; henceforth all parameters are input parameters,
+ * no exceptions. It is usable to enumerate all the io classes.
+ *
+ * @param[in] cache cache id of cache for which data is being retrieved
+ * @param[in] io_class_id id of an io class for which callback herein
+ * is invoked.
+ * @param[in] cntx a context pointer passed herein from within
+ * ocf_io_class_visit down to this callback.
+ *
+ * @return 0 upon success; Nonzero upon failure (when nonzero is returned,
+ * this callback won't be invoked for any more io classes)
+ */
+typedef int (*ocf_io_class_visitor_t)(ocf_cache_t cache,
+ uint32_t io_class_id, void *cntx);
+
+/**
+ * @brief enumerate all of the available IO classes.
+ *
+ * This function allows enumeration and retrieval of all io class id's that
+ * are valid for given cache id via visiting all those with callback function
+ * that is supplied by caller.
+ *
+ * @param[in] cache cache id to which given call pertains
+ * @param[in] visitor a callback function that will be issued for each and every
+ * IO class that is configured and valid within given cache instance
+ * @param[in] cntx a context variable - structure that shall be passed to a
+ * callback function for every call
+ *
+ * @return 0 upon successful completion of the function; otherwise nonzero result
+ * shall be returned
+ */
+int ocf_io_class_visit(ocf_cache_t cache, ocf_io_class_visitor_t visitor,
+ void *cntx);
+
+#endif /* __OCF_IO_CLASS_H__ */
diff --git a/src/spdk/ocf/inc/ocf_logger.h b/src/spdk/ocf/inc/ocf_logger.h
new file mode 100644
index 000000000..343a9759f
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_logger.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_LOGGER_H__
+#define __OCF_LOGGER_H__
+
+/**
+ * @file
+ * @brief Logger API
+ */
+
+#include <ocf/ocf_types.h>
+#include <stdarg.h>
+
+/**
+ * @brief Verbosity levels of context log
+ */
+typedef enum {
+ log_emerg,
+ log_alert,
+ log_crit,
+ log_err,
+ log_warn,
+ log_notice,
+ log_info,
+ log_debug,
+} ocf_logger_lvl_t;
+
+struct ocf_logger_ops {
+ int (*open)(ocf_logger_t logger);
+ void (*close)(ocf_logger_t logger);
+ int (*print)(ocf_logger_t logger, ocf_logger_lvl_t lvl,
+ const char *fmt, va_list args);
+ int (*print_rl)(ocf_logger_t logger, const char *func_name);
+ int (*dump_stack)(ocf_logger_t logger);
+};
+
+void ocf_logger_set_priv(ocf_logger_t logger, void *priv);
+
+void *ocf_logger_get_priv(ocf_logger_t logger);
+
+#endif /* __OCF_LOGGER_H__ */
diff --git a/src/spdk/ocf/inc/ocf_metadata.h b/src/spdk/ocf/inc/ocf_metadata.h
new file mode 100644
index 000000000..5ecfbcaef
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_metadata.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_METADATA_H__
+#define __OCF_METADATA_H__
+
+/**
+ * @file
+ * @brief OCF metadata helper function
+ *
+ * Those functions can be used by volume implementation.
+ */
+
+/**
+ * @brief Atomic metadata for extended sector
+ *
+ * @warning The size of this structure has to be equal 8 bytes
+ */
+struct ocf_atomic_metadata {
+ /** Core line of core (in cache line size unit) which are cached */
+ uint64_t core_line : 46;
+
+ /** Core sequence number to which this line belongs to*/
+ uint32_t core_seq_no : 16;
+
+ /** Set bit indicates that given sector is valid (is cached) */
+ uint32_t valid : 1;
+
+ /** Set bit indicates that sector i dirty */
+ uint32_t dirty : 1;
+} __attribute__((packed));
+
+#define OCF_ATOMIC_METADATA_SIZE sizeof(struct ocf_atomic_metadata)
+
+/**
+ * @brief Get metadata entry (cache mapping) for specified sector of cache
+ * device
+ *
+ * Metadata has sector granularity. It might be used by volume which
+ * supports atomic writes - (write of data and metadata in one buffer)
+ *
+ * @param[in] cache OCF cache instance
+ * @param[in] addr Sector address in bytes
+ * @param[out] entry Metadata entry
+ *
+ * @retval 0 Metadata retrieved successfully
+ * @retval Non-zero Error
+ */
+int ocf_metadata_get_atomic_entry(ocf_cache_t cache, uint64_t addr,
+ struct ocf_atomic_metadata *entry);
+
+/**
+ * @brief Metadata probe status
+ */
+struct ocf_metadata_probe_status {
+ /** Cache was graceful stopped */
+ bool clean_shutdown;
+
+ /** Cache contains dirty data */
+ bool cache_dirty;
+
+ /** Loaded name of cache instance */
+ char cache_name[OCF_CACHE_NAME_SIZE];
+};
+
+/**
+ * @brief Metadata probe completion callback
+ *
+ * @param[in] priv Completion context
+ * @param[in] error Error code (zero on success)
+ * @param[in] status Structure describing metadata probe status
+ */
+typedef void (*ocf_metadata_probe_end_t)(void *priv, int error,
+ struct ocf_metadata_probe_status *status);
+
+/**
+ * @brief Probe cache device
+ *
+ * @param[in] ctx handle to object designating ocf context
+ * @param[in] volume Cache volume
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion context
+ */
+void ocf_metadata_probe(ocf_ctx_t ctx, ocf_volume_t volume,
+ ocf_metadata_probe_end_t cmpl, void *priv);
+
+/**
+ * @brief Metadata probe for cores completion callback
+ *
+ * @param[in] priv Completion context
+ * @param[in] error Error code (zero on success)
+ * @param[in] num_cores Number of cores in cache metadata
+ */
+typedef void (*ocf_metadata_probe_cores_end_t)(void *priv, int error,
+ unsigned int num_cores);
+
+/**
+ * @brief Probe cache device for associated cores
+ *
+ * @param[in] ctx handle to object designating ocf context
+ * @param[in] volume Cache volume
+ * @param[in,out] uuids Array of uuids
+ * @param[in] uuid_count Size of @uuid array
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion context
+ */
+void ocf_metadata_probe_cores(ocf_ctx_t ctx, ocf_volume_t volume,
+ struct ocf_volume_uuid *uuids, uint32_t uuid_count,
+ ocf_metadata_probe_cores_end_t cmpl, void *priv);
+
+/**
+ * @brief Check if sectors in cache line before given address are invalid
+ *
+ * It might be used by volume which supports
+ * atomic writes - (write of data and metadata in one buffer)
+ *
+ * @param[in] cache OCF cache instance
+ * @param[in] addr Sector address in bytes
+ *
+ * @retval 0 Not all sectors before given address are invalid
+ * @retval Non-zero Number of sectors before given address
+ */
+int ocf_metadata_check_invalid_before(ocf_cache_t cache, uint64_t addr);
+
+/**
+ * @brief Check if sectors in cache line after given end address are invalid
+ *
+ * It might be used by volume which supports
+ * atomic writes - (write of data and metadata in one buffer)
+ *
+ * @param[in] cache OCF cache instance
+ * @param[in] addr Sector address in bytes
+ * @param[in] bytes IO size in bytes
+ *
+ * @retval 0 Not all sectors after given end address are invalid
+ * @retval Non-zero Number of sectors after given end address
+ */
+int ocf_metadata_check_invalid_after(ocf_cache_t cache, uint64_t addr,
+ uint32_t bytes);
+
+#endif /* __OCF_METADATA_H__ */
diff --git a/src/spdk/ocf/inc/ocf_metadata_updater.h b/src/spdk/ocf/inc/ocf_metadata_updater.h
new file mode 100644
index 000000000..7a5084f2d
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_metadata_updater.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_METADATA_UPDATER_H__
+#define __OCF_METADATA_UPDATER_H__
+
+/**
+ * @file
+ * @brief OCF metadata updater API
+ *
+ */
+
+/**
+ * @brief Run metadata updater
+ *
+ * @param[in] mu Metadata updater instance to run
+ *
+ * @retval Hint if there is need to rerun without waiting.
+ */
+uint32_t ocf_metadata_updater_run(ocf_metadata_updater_t mu);
+
+/**
+ * @brief Set metadata updater private data
+ *
+ * @param[in] c Metadata updater handle
+ * @param[in] priv Private data
+ */
+void ocf_metadata_updater_set_priv(ocf_metadata_updater_t mu, void *priv);
+
+/**
+ * @brief Get metadata updater private data
+ *
+ * @param[in] c Metadata updater handle
+ *
+ * @retval Metadata updater private data
+ */
+void *ocf_metadata_updater_get_priv(ocf_metadata_updater_t mu);
+
+/**
+ * @brief Get cache instance to which metadata updater belongs
+ *
+ * @param[in] c Metadata updater handle
+ *
+ * @retval Cache instance
+ */
+ocf_cache_t ocf_metadata_updater_get_cache(ocf_metadata_updater_t mu);
+
+#endif /* __OCF_METADATA_UPDATER_H__ */
diff --git a/src/spdk/ocf/inc/ocf_mngt.h b/src/spdk/ocf/inc/ocf_mngt.h
new file mode 100644
index 000000000..e4dd0cbc7
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_mngt.h
@@ -0,0 +1,1107 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_MNGT_H__
+#define __OCF_MNGT_H__
+
+#include "ocf_cache.h"
+#include "ocf_core.h"
+
+/**
+ * @file
+ * @brief OCF management operations definitions
+ */
+
+/**
+ * @brief Core start configuration
+ */
+struct ocf_mngt_core_config {
+ /**
+ * @brief OCF core name
+ */
+ char name[OCF_CORE_NAME_SIZE];
+
+ /**
+ * @brief OCF core volume UUID
+ */
+ struct ocf_volume_uuid uuid;
+
+ /**
+ * @brief OCF core volume type
+ */
+ uint8_t volume_type;
+
+ /**
+ * @brief Add core to pool if cache isn't present or add core to
+ * earlier loaded cache
+ */
+ bool try_add;
+
+ uint32_t seq_cutoff_threshold;
+ /*!< Sequential cutoff threshold (in bytes) */
+
+ struct {
+ void *data;
+ size_t size;
+ } user_metadata;
+};
+
+/**
+ * @brief Initialize core config to default values
+ *
+ * @note This function doesn't initialize name, uuid and volume_type fields
+ * which have no default values and are required to be set by user.
+ *
+ * @param[in] cfg Core config stucture
+ */
+static inline void ocf_mngt_core_config_set_default(
+ struct ocf_mngt_core_config *cfg)
+{
+ cfg->try_add = false;
+ cfg->seq_cutoff_threshold = 1024;
+ cfg->user_metadata.data = NULL;
+ cfg->user_metadata.size = 0;
+}
+
+/**
+ * @brief Get number of OCF caches
+ *
+ * @param[in] ctx OCF context
+ *
+ * @retval Number of caches in given OCF instance
+ */
+uint32_t ocf_mngt_cache_get_count(ocf_ctx_t ctx);
+
+/* Cache instances getters */
+
+/**
+ * @brief Get OCF cache by name
+ *
+ * @note This function on success also increases reference counter
+ * in given cache
+ *
+ * @param[in] ctx OCF context
+ * @param[in] name OCF cache name
+ * @param[in] name_len Cache name length
+ * @param[out] cache OCF cache handle
+ *
+ * @retval 0 Get cache successfully
+ * @retval -OCF_ERR_CACHE_NOT_EXIST Cache with given name doesn't exist
+ */
+int ocf_mngt_cache_get_by_name(ocf_ctx_t ctx, const char* name, size_t name_len,
+ ocf_cache_t *cache);
+
+/**
+ * @brief Increment reference counter of cache
+ *
+ * @param[in] cache OCF cache handle
+ *
+ * @retval 0 Reference counter incremented
+ * @retval -OCF_ERR_CACHE_NOT_AVAIL cache isn't initialised yet
+ */
+int ocf_mngt_cache_get(ocf_cache_t cache);
+
+/**
+ * @brief Decrease reference counter in cache
+ *
+ * @note If cache don't have any reference - deallocate it
+ *
+ * @param[in] cache Handle to cache
+ */
+void ocf_mngt_cache_put(ocf_cache_t cache);
+
+/**
+ * @brief Lock cache for management oparations (write lock, exclusive)
+
+ * @param[in] cache Handle to cache
+ * @param[in] error Status error code. Can be one of the following:
+ * 0 Cache successfully locked
+ * -OCF_ERR_CACHE_NOT_EXIST Can not lock cache - cache is already stopping
+ * -OCF_ERR_NO_MEM Cannot allocate needed memory
+ * -OCF_ERR_INTR Wait operation interrupted
+ */
+typedef void (*ocf_mngt_cache_lock_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Lock cache for management oparations (write lock, exclusive)
+ *
+ * @param[in] cache Handle to cache
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Private context of completion callback
+ */
+void ocf_mngt_cache_lock(ocf_cache_t cache,
+ ocf_mngt_cache_lock_end_t cmpl, void *priv);
+
+/**
+ * @brief Lock cache for read - assures cache config does not change while
+ * lock is being held, while allowing other users to acquire
+ * read lock in parallel.
+ *
+ * @param[in] cache Handle to cache
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Private context of completion callback
+ */
+void ocf_mngt_cache_read_lock(ocf_cache_t cache,
+ ocf_mngt_cache_lock_end_t cmpl, void *priv);
+
+/**
+ * @brief Lock cache for management oparations (write lock, exclusive)
+ *
+ * @param[in] cache Handle to cache
+ *
+ * @retval 0 Cache successfully locked
+ * @retval -OCF_ERR_CACHE_NOT_EXIST Can not lock cache - cache is already
+ * stopping
+ * @retval -OCF_ERR_NO_LOCK Lock not acquired
+ */
+int ocf_mngt_cache_trylock(ocf_cache_t cache);
+
+/**
+ * @brief Lock cache for read - assures cache config does not change while
+ * lock is being held, while allowing other users to acquire
+ * read lock in parallel.
+ *
+ * @param[in] cache Handle to cache
+ *
+ * @retval 0 Cache successfully locked
+ * @retval -OCF_ERR_CACHE_NOT_EXIST Can not lock cache - cache is already
+ * stopping
+ * @retval -OCF_ERR_NO_LOCK Lock not acquired
+ */
+int ocf_mngt_cache_read_trylock(ocf_cache_t cache);
+
+/**
+ * @brief Write-unlock cache
+ *
+ * @param[in] cache Handle to cache
+ */
+void ocf_mngt_cache_unlock(ocf_cache_t cache);
+
+/**
+ * @brief Read-unlock cache
+ *
+ * @param[in] cache Handle to cache
+ */
+void ocf_mngt_cache_read_unlock(ocf_cache_t cache);
+
+/**
+ * @brief Cache visitor function
+ *
+ * @param[in] cache Handle to cache
+ * @param[in] cntx Visitor function context
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+typedef int (*ocf_mngt_cache_visitor_t)(ocf_cache_t cache, void *cntx);
+
+/**
+ * @brief Loop for each cache
+ *
+ * @note Visitor function is called for each cache
+ *
+ * @param[in] ctx OCF context
+ * @param[in] visitor OCF cache visitor function
+ * @param[in] cntx Context for cache visitor function
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_mngt_cache_visit(ocf_ctx_t ctx, ocf_mngt_cache_visitor_t visitor,
+ void *cntx);
+
+/**
+ * @brief Loop for each cache reverse
+ *
+ * @note Visitor function is called for each cache
+ *
+ * @param[in] ctx OCF context
+ * @param[in] visitor OCF cache visitor function
+ * @param[in] cntx Context for cache visitor function
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_mngt_cache_visit_reverse(ocf_ctx_t ctx, ocf_mngt_cache_visitor_t visitor,
+ void *cntx);
+
+/**
+ * @brief Cache start configuration
+ */
+struct ocf_mngt_cache_config {
+ /**
+ * @brief Cache name
+ */
+ char name[OCF_CACHE_NAME_SIZE];
+
+ /**
+ * @brief Cache mode
+ */
+ ocf_cache_mode_t cache_mode;
+
+ /**
+ * @brief Eviction policy type
+ */
+ ocf_eviction_t eviction_policy;
+
+ /**
+ * @brief Promotion policy type
+ */
+ ocf_promotion_t promotion_policy;
+
+ /**
+ * @brief Cache line size
+ */
+ ocf_cache_line_size_t cache_line_size;
+
+ /**
+ * @brief Metadata layout (stripping/sequential)
+ */
+ ocf_metadata_layout_t metadata_layout;
+
+ bool metadata_volatile;
+
+ /**
+ * @brief Backfill configuration
+ */
+ struct {
+ uint32_t max_queue_size;
+ uint32_t queue_unblock_size;
+ } backfill;
+
+ /**
+ * @brief Start cache and keep it locked
+ *
+ * @note In this case caller is able to perform additional activities
+ * and then shall unlock cache
+ */
+ bool locked;
+
+ /**
+ * @brief Use pass-through mode for I/O requests unaligned to 4KiB
+ */
+ bool pt_unaligned_io;
+
+ /**
+ * @brief If set, try to submit all I/O in fast path.
+ */
+ bool use_submit_io_fast;
+};
+
+/**
+ * @brief Initialize core config to default values
+ *
+ * @note This function doesn't initialize name field which has no default
+ * value and is required to be set by user.
+ *
+ * @param[in] cfg Cache config stucture
+ */
+static inline void ocf_mngt_cache_config_set_default(
+ struct ocf_mngt_cache_config *cfg)
+{
+ cfg->cache_mode = ocf_cache_mode_default;
+ cfg->eviction_policy = ocf_eviction_default;
+ cfg->promotion_policy = ocf_promotion_default;
+ cfg->cache_line_size = ocf_cache_line_size_4;
+ cfg->metadata_layout = ocf_metadata_layout_default;
+ cfg->metadata_volatile = false;
+ cfg->backfill.max_queue_size = 65536;
+ cfg->backfill.queue_unblock_size = 60000;
+ cfg->locked = false;
+ cfg->pt_unaligned_io = false;
+ cfg->use_submit_io_fast = false;
+}
+
+/**
+ * @brief Start cache instance
+ *
+ * @param[in] ctx OCF context
+ * @param[out] cache Cache handle
+ * @param[in] cfg Starting cache configuration
+ *
+ * @retval 0 Cache started successfully
+ * @retval Non-zero Error occurred and starting cache failed
+ */
+int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
+ struct ocf_mngt_cache_config *cfg);
+
+/**
+ * @brief Set queue to be used during management operations
+ *
+ * @param[in] cache Cache object
+ * @param[in] queue Queue object
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error occurred
+ */
+int ocf_mngt_cache_set_mngt_queue(ocf_cache_t cache, ocf_queue_t queue);
+
+/**
+ * @brief Completion callback of cache stop operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_stop_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Stop cache instance
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_stop(ocf_cache_t cache,
+ ocf_mngt_cache_stop_end_t cmpl, void *priv);
+
+/**
+ * @brief Cache attach configuration
+ */
+struct ocf_mngt_cache_device_config {
+ /**
+ * @brief Cache volume UUID
+ */
+ struct ocf_volume_uuid uuid;
+
+ /**
+ * @brief Cache volume type
+ */
+ uint8_t volume_type;
+
+ /**
+ * @brief Cache line size
+ */
+ ocf_cache_line_size_t cache_line_size;
+
+ /**
+ * @brief Automatically open core volumes when loading cache
+ *
+ * If set to false, cache load will not attempt to open core volumes,
+ * and so cores will be marked "inactive" unless their volumes were
+ * earlier added to the core pool. In such case user will be expected
+ * to add cores later using function ocf_mngt_cache_add_core().
+ *
+ * @note This option is meaningful only with ocf_mngt_cache_load().
+ * When used with ocf_mngt_cache_attach() it's ignored.
+ */
+ bool open_cores;
+
+ /**
+ * @brief Ignore warnings and start cache
+ *
+ * @note It will force starting cache despite the:
+ * - overwrite dirty shutdown of previous cache
+ * - ignore cache with dirty shutdown and reinitialize cache
+ */
+ bool force;
+
+ /**
+ * @brief If set, cache features (like discard) are tested
+ * before starting cache
+ */
+ bool perform_test;
+
+ /**
+ * @brief If set, cache device will be discarded on cache start
+ */
+ bool discard_on_start;
+
+ /**
+ * @brief Optional opaque volume parameters, passed down to cache volume
+ * open callback
+ */
+ void *volume_params;
+};
+
+/**
+ * @brief Initialize core config to default values
+ *
+ * @note This function doesn't initiialize uuid and volume_type fields
+ * which have no default values and are required to be set by user.
+ *
+ * @param[in] cfg Cache device config stucture
+ */
+static inline void ocf_mngt_cache_device_config_set_default(
+ struct ocf_mngt_cache_device_config *cfg)
+{
+ cfg->cache_line_size = ocf_cache_line_size_none;
+ cfg->open_cores = true;
+ cfg->force = false;
+ cfg->perform_test = true;
+ cfg->discard_on_start = true;
+ cfg->volume_params = NULL;
+}
+
+/**
+ * @brief Get amount of free RAM needed to attach cache volume
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cfg Caching device configuration
+ * @param[out] ram_needed Amount of RAM needed in bytes
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error occurred
+ */
+int ocf_mngt_get_ram_needed(ocf_cache_t cache,
+ struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed);
+
+/**
+ * @brief Completion callback of cache attach operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_attach_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Attach caching device to cache instance
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cfg Caching device configuration
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_attach(ocf_cache_t cache,
+ struct ocf_mngt_cache_device_config *cfg,
+ ocf_mngt_cache_attach_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of cache detach operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_detach_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Detach caching cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_detach(ocf_cache_t cache,
+ ocf_mngt_cache_detach_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of cache load operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_load_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Load cache instance
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cfg Caching device configuration
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_load(ocf_cache_t cache,
+ struct ocf_mngt_cache_device_config *cfg,
+ ocf_mngt_cache_load_end_t cmpl, void *priv);
+
+/* Adding and removing cores */
+
+/**
+ * @brief Completion callback of add core operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] core Core handle on success or NULL on failure
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_add_core_end_t)(ocf_cache_t cache,
+ ocf_core_t core, void *priv, int error);
+
+/**
+ * @brief Add core to cache instance
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cfg Core configuration
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_add_core(ocf_cache_t cache,
+ struct ocf_mngt_core_config *cfg,
+ ocf_mngt_cache_add_core_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of remove core operation
+ *
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_remove_core_end_t)(void *priv, int error);
+
+/**
+ * @brief Remove core from cache instance
+ *
+ * @param[in] core Core handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_remove_core(ocf_core_t core,
+ ocf_mngt_cache_remove_core_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of detach core operation
+ *
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_detach_core_end_t)(void *priv, int error);
+
+/**
+ * @brief Detach core from cache instance
+ *
+ * @param[in] core Core handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_detach_core(ocf_core_t core,
+ ocf_mngt_cache_detach_core_end_t cmpl, void *priv);
+
+/* Flush operations */
+
+/**
+ * @brief Completion callback of cache flush operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_flush_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Flush data from given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_flush(ocf_cache_t cache,
+ ocf_mngt_cache_flush_end_t cmpl, void *priv);
+
+/**
+ * @brief Check if core is dirty
+ *
+ * @param[in] core Core handle
+ *
+ * @retval true if core is dirty, false otherwise
+ */
+bool ocf_mngt_core_is_dirty(ocf_core_t core);
+
+/**
+ * @brief Check if cache is dirty
+ *
+ * @param[in] cache Cache handle
+ *
+ * @retval true if cache is dirty, false otherwise
+ */
+bool ocf_mngt_cache_is_dirty(ocf_cache_t cache);
+
+/**
+ * @brief Completion callback of core flush operation
+ *
+ * @param[in] core Core handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_core_flush_end_t)(ocf_core_t core,
+ void *priv, int error);
+
+/**
+ * @brief Flush data to given core
+ *
+ * @param[in] core Core handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_core_flush(ocf_core_t core,
+ ocf_mngt_core_flush_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of cache purge operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_purge_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Purge data from given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_purge(ocf_cache_t cache,
+ ocf_mngt_cache_purge_end_t cmpl, void *priv);
+
+/**
+ * @brief Completion callback of core purge operation
+ *
+ * @param[in] core Core handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_core_purge_end_t)(ocf_core_t core,
+ void *priv, int error);
+
+/**
+ * @brief Purge data to given core
+ *
+ * @param[in] core Core handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_core_purge(ocf_core_t core,
+ ocf_mngt_core_purge_end_t cmpl, void *priv);
+
+/**
+ * @brief Interrupt existing flushing of cache or core
+ *
+ * @param[in] cache Cache instance
+ */
+void ocf_mngt_cache_flush_interrupt(ocf_cache_t cache);
+
+/**
+ * @brief Completion callback of save operation
+ *
+ * @param[in] cache Cache handle
+ * @param[in] priv Callback context
+ * @param[in] error Error code (zero on success)
+ */
+typedef void (*ocf_mngt_cache_save_end_t)(ocf_cache_t cache,
+ void *priv, int error);
+
+/**
+ * @brief Save cache configuration data on cache volume
+ *
+ * This function should be called after changing cache or core parameters
+ * in order to make changes persistent.
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cmpl Completion callback
+ * @param[in] priv Completion callback context
+ */
+void ocf_mngt_cache_save(ocf_cache_t cache,
+ ocf_mngt_cache_save_end_t cmpl, void *priv);
+
+/**
+ * @brief Determines whether given cache mode has write-back semantics, i.e. it
+ * allows for writes to be serviced in cache and lazily propagated to core.
+ *
+ * @param[in] mode input cache mode
+ */
+static inline bool ocf_mngt_cache_mode_has_lazy_write(ocf_cache_mode_t mode)
+{
+ return mode == ocf_cache_mode_wb || mode == ocf_cache_mode_wo;
+}
+
+/**
+ * @brief Set cache mode in given cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] mode Cache mode to set
+ *
+ * @retval 0 Cache mode have been set successfully
+ * @retval Non-zero Error occurred and cache mode not been set
+ */
+int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode);
+
+/**
+ * @brief Set cleaning policy in given cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Cleaning policy type
+ *
+ * @retval 0 Policy has been set successfully
+ * @retval Non-zero Error occurred and policy has not been set
+ */
+int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type);
+
+/**
+ * @brief Get current cleaning policy from given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[out] type Variable to store current cleaning policy type
+ *
+ * @retval 0 Policy has been get successfully
+ * @retval Non-zero Error occurred and policy has not been get
+ */
+int ocf_mngt_cache_cleaning_get_policy(ocf_cache_t cache, ocf_cleaning_t *type);
+
+/**
+ * @brief Set cleaning parameter in given cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Cleaning policy type
+ * @param[in] param_id Cleaning policy parameter id
+ * @param[in] param_value Cleaning policy parameter value
+ *
+ * @retval 0 Parameter has been set successfully
+ * @retval Non-zero Error occurred and parameter has not been set
+ */
+int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
+ uint32_t param_id, uint32_t param_value);
+
+/**
+ * @brief Get cleaning parameter from given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Cleaning policy type
+ * @param[in] param_id Cleaning policy parameter id
+ * @param[out] param_value Variable to store parameter value
+ *
+ * @retval 0 Parameter has been get successfully
+ * @retval Non-zero Error occurred and parameter has not been get
+ */
+int ocf_mngt_cache_cleaning_get_param(ocf_cache_t cache,ocf_cleaning_t type,
+ uint32_t param_id, uint32_t *param_value);
+
+/**
+ * @brief Set promotion policy in given cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Promotion policy type
+ *
+ * @retval 0 Policy has been set successfully
+ * @retval Non-zero Error occurred and policy has not been set
+ */
+int ocf_mngt_cache_promotion_set_policy(ocf_cache_t cache, ocf_promotion_t type);
+
+/**
+ * @brief Get promotion policy in given cache
+ *
+ * @param[in] cache Cache handle
+ *
+ * @retval Currently set promotion policy type
+ */
+ocf_promotion_t ocf_mngt_cache_promotion_get_policy(ocf_cache_t cache);
+
+/**
+ * @brief Set promotion policy parameter for given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Promotion policy type
+ * @param[in] param_id Promotion policy parameter id
+ * @param[in] param_value Promotion policy parameter value
+ *
+ * @retval 0 Parameter has been set successfully
+ * @retval Non-zero Error occurred and parameter has not been set
+ */
+int ocf_mngt_cache_promotion_set_param(ocf_cache_t cache, ocf_promotion_t type,
+ uint8_t param_id, uint32_t param_value);
+
+/**
+ * @brief Get promotion policy parameter for given cache
+ *
+ * @param[in] cache Cache handle
+ * @param[in] type Promotion policy type
+ * @param[in] param_id Promotion policy parameter id
+ * @param[out] param_value Variable to store parameter value
+ *
+ * @retval 0 Parameter has been retrieved successfully
+ * @retval Non-zero Error occurred and parameter has not been retrieved
+ */
+int ocf_mngt_cache_promotion_get_param(ocf_cache_t cache, ocf_promotion_t type,
+ uint8_t param_id, uint32_t *param_value);
+
+/**
+ * @brief IO class configuration
+ */
+struct ocf_mngt_io_class_config {
+ /**
+ * @brief IO class ID
+ */
+ uint32_t class_id;
+
+ /**
+ * @brief IO class name
+ */
+ const char *name;
+
+ /**
+ * @brief IO class eviction priority
+ */
+ int16_t prio;
+
+ /**
+ * @brief IO class cache mode
+ */
+ ocf_cache_mode_t cache_mode;
+
+ /**
+ * @brief IO class minimum size
+ */
+ uint32_t min_size;
+
+ /**
+ * @brief IO class maximum size
+ */
+ uint32_t max_size;
+};
+
+struct ocf_mngt_io_classes_config {
+ struct ocf_mngt_io_class_config config[OCF_IO_CLASS_MAX];
+};
+
+/**
+ * @brief Configure IO classes in given cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] cfg IO class configuration
+ *
+ * @retval 0 Configuration have been set successfully
+ * @retval Non-zero Error occurred and configuration not been set
+ */
+int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
+ const struct ocf_mngt_io_classes_config *cfg);
+
+/**
+ * @brief Asociate new UUID value with given core
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] core Core object
+ * @param[in] uuid new core uuid
+ *
+ * @retval 0 Success
+ * @retval Non-zero Fail
+ */
+int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid);
+
+/**
+ * @brief Set persistent user metadata for given core
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] core Core object
+ * @param[in] data User data buffer
+ * @param[in] size Size of user data buffer
+ *
+ * @retval 0 Success
+ * @retval Non-zero Core getting failed
+ */
+int ocf_mngt_core_set_user_metadata(ocf_core_t core, void *data, size_t size);
+
+/**
+ * @brief Get persistent user metadata from given core
+ *
+ * @param[in] core Core object
+ * @param[out] data User data buffer
+ * @param[in] size Size of user data buffer
+ *
+ * @retval 0 Success
+ * @retval Non-zero Core getting failed
+ */
+int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size);
+
+/**
+ * @brief Set core sequential cutoff threshold
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] core Core handle
+ * @param[in] thresh threshold in bytes for sequential cutoff
+ *
+ * @retval 0 Sequential cutoff threshold has been set successfully
+ * @retval Non-zero Error occured and threshold hasn't been updated
+ */
+int ocf_mngt_core_set_seq_cutoff_threshold(ocf_core_t core, uint32_t thresh);
+
+/**
+ * @brief Set sequential cutoff threshold for all cores in cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] thresh threshold in bytes for sequential cutoff
+ *
+ * @retval 0 Sequential cutoff threshold has been set successfully
+ * @retval Non-zero Error occured and threshold hasn't been updated
+ */
+int ocf_mngt_core_set_seq_cutoff_threshold_all(ocf_cache_t cache,
+ uint32_t thresh);
+
+/**
+ * @brief Get core sequential cutoff threshold
+ *
+ * @param[in] core Core handle
+ * @param[in] thresh threshold in bytes for sequential cutoff
+ *
+ * @retval 0 Sequential cutoff threshold has been get successfully
+ * @retval Non-zero Error occured
+ */
+int ocf_mngt_core_get_seq_cutoff_threshold(ocf_core_t core, uint32_t *thresh);
+
+/**
+ * @brief Set core sequential cutoff policy
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] core Core handle
+ * @param[in] policy sequential cutoff policy
+ *
+ * @retval 0 Sequential cutoff policy has been set successfully
+ * @retval Non-zero Error occured and policy hasn't been updated
+ */
+int ocf_mngt_core_set_seq_cutoff_policy(ocf_core_t core,
+ ocf_seq_cutoff_policy policy);
+
+/**
+ * @brief Set sequential cutoff policy for all cores in cache
+ *
+ * @attention This changes only runtime state. To make changes persistent
+ * use function ocf_mngt_cache_save().
+ *
+ * @param[in] cache Cache handle
+ * @param[in] policy sequential cutoff policy
+ *
+ * @retval 0 Sequential cutoff policy has been set successfully
+ * @retval Non-zero Error occured and policy hasn't been updated
+ */
+int ocf_mngt_core_set_seq_cutoff_policy_all(ocf_cache_t cache,
+ ocf_seq_cutoff_policy policy);
+
+/**
+ * @brief Get core sequential cutoff policy
+ *
+ * @param[in] core Core handle
+ * @param[in] policy sequential cutoff policy
+ *
+ * @retval 0 Sequential cutoff policy has been get successfully
+ * @retval Non-zero Error occured
+ */
+int ocf_mngt_core_get_seq_cutoff_policy(ocf_core_t core,
+ ocf_seq_cutoff_policy *policy);
+
+/**
+ * @brief Set cache fallback Pass Through error threshold
+ *
+ * @param[in] cache Cache handle
+ * @param[in] threshold Value to be set as threshold
+ *
+ * @retval 0 Fallback-PT threshold have been set successfully
+ * @retval Non-zero Error occurred
+ */
+int ocf_mngt_cache_set_fallback_pt_error_threshold(ocf_cache_t cache,
+ uint32_t threshold);
+
+/**
+ * @brief Get cache fallback Pass Through error threshold
+ *
+ * @param[in] cache Cache handle
+ * @param[out] threshold Fallback-PT threshold
+ *
+ * @retval 0 Fallback-PT threshold have been get successfully
+ * @retval Non-zero Error occurred
+ */
+int ocf_mngt_cache_get_fallback_pt_error_threshold(ocf_cache_t cache,
+ uint32_t *threshold);
+
+/**
+ * @brief Reset cache fallback Pass Through error counter
+ *
+ * @param[in] cache Cache handle
+ *
+ * @retval 0 Threshold have been reset successfully
+ */
+int ocf_mngt_cache_reset_fallback_pt_error_counter(ocf_cache_t cache);
+
+/**
+ * @brief Get core pool count
+ *
+ * @param[in] ctx OCF context
+ *
+ * @retval Number of cores in core pool
+ */
+int ocf_mngt_core_pool_get_count(ocf_ctx_t ctx);
+
+/**
+ * @brief Add core to pool
+ *
+ * @param[in] ctx OCF context
+ * @param[in] uuid Cache volume UUID
+ * @param[in] type OCF core volume type
+ *
+ * @retval 0 Core added to pool successfully
+ * @retval Non-zero Error occurred and adding core to poll failed
+ */
+int ocf_mngt_core_pool_add(ocf_ctx_t ctx, ocf_uuid_t uuid, uint8_t type);
+
+/**
+ * @brief Add core to pool
+ *
+ * @param[in] ctx OCF context
+ * @param[in] uuid Cache volume UUID
+ * @param[in] type OCF core volume type
+ *
+ * @retval Handler to object with same UUID
+ * @retval NULL Not found object with that id
+ */
+ocf_volume_t ocf_mngt_core_pool_lookup(ocf_ctx_t ctx, ocf_uuid_t uuid,
+ ocf_volume_type_t type);
+/**
+ * @brief Iterate over all object in pool and call visitor callback
+ *
+ * @param[in] ctx OCF context
+ * @param[in] visitor Visitor callback
+ * @param[in] visior_ctx CContext for visitor callback
+ *
+ * @retval Handler to object with same UUID
+ * @retval NULL Not found object with that id
+ */
+int ocf_mngt_core_pool_visit(ocf_ctx_t ctx,
+ int (*visitor)(ocf_uuid_t, void *), void *visitor_ctx);
+
+/**
+ * @brief Remove volume from pool
+ *
+ * Important: This function destroys volume instance but doesn't close it,
+ * so it should be either moved or closed before calling this function.
+ *
+ * @param[in] ctx OCF context
+ * @param[in] volume Core volume
+ */
+void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_volume_t volume);
+
+#endif /* __OCF_CACHE_H__ */
diff --git a/src/spdk/ocf/inc/ocf_queue.h b/src/spdk/ocf/inc/ocf_queue.h
new file mode 100644
index 000000000..3d795cd4e
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_queue.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef OCF_QUEUE_H_
+#define OCF_QUEUE_H_
+
+/**
+ * @file
+ * @brief OCF queues API
+ */
+
+/**
+ * @brief I/O queue operations
+ */
+struct ocf_queue_ops {
+ /**
+ * @brief Kick I/O queue processing
+ *
+ * This function should inform worker, thread or any other queue
+ * processing mechanism, that there are new requests in queue to
+ * be processed. Processing requests synchronously in this function
+ * is not allowed.
+ *
+ * @param[in] q I/O queue to be kicked
+ */
+ void (*kick)(ocf_queue_t q);
+
+ /**
+ * @brief Kick I/O queue processing
+ *
+ * This function should inform worker, thread or any other queue
+ * processing mechanism, that there are new requests in queue to
+ * be processed. Function kick_sync is allowed to process requests
+ * synchronously without delegating them to the worker.
+ *
+ * @param[in] q I/O queue to be kicked
+ */
+ void (*kick_sync)(ocf_queue_t q);
+
+ /**
+ * @brief Stop I/O queue
+ *
+ * @param[in] q I/O queue beeing stopped
+ */
+ void (*stop)(ocf_queue_t q);
+};
+
+/**
+ * @brief Allocate IO queue and add it to list in cache
+ *
+ * @param[in] cache Handle to cache instance
+ * @param[out] queue Handle to created queue
+ * @param[in] ops Queue operations
+ *
+ * @return Zero on success, otherwise error code
+ */
+int ocf_queue_create(ocf_cache_t cache, ocf_queue_t *queue,
+ const struct ocf_queue_ops *ops);
+
+/**
+ * @brief Increase reference counter in queue
+ *
+ * @param[in] queue Queue
+ *
+ */
+void ocf_queue_get(ocf_queue_t queue);
+
+/**
+ * @brief Decrease reference counter in queue
+ *
+ * @note If queue don't have any reference - deallocate it
+ *
+ * @param[in] queue Queue
+ *
+ */
+void ocf_queue_put(ocf_queue_t queue);
+
+/**
+ * @brief Process single request from queue
+ *
+ * @param[in] q Queue to run
+ */
+void ocf_queue_run_single(ocf_queue_t q);
+
+/**
+ * @brief Run queue processing
+ *
+ * @param[in] q Queue to run
+ */
+void ocf_queue_run(ocf_queue_t q);
+
+/**
+ * @brief Set queue private data
+ *
+ * @param[in] q I/O queue
+ * @param[in] priv Private data
+ */
+void ocf_queue_set_priv(ocf_queue_t q, void *priv);
+
+/**
+ * @brief Get queue private data
+ *
+ * @param[in] q I/O queue
+ *
+ * @retval I/O queue private data
+ */
+void *ocf_queue_get_priv(ocf_queue_t q);
+
+/**
+ * @brief Get number of pending requests in I/O queue
+ *
+ * @param[in] q I/O queue
+ *
+ * @retval Number of pending requests in I/O queue
+ */
+uint32_t ocf_queue_pending_io(ocf_queue_t q);
+
+/**
+ * @brief Get cache instance to which I/O queue belongs
+ *
+ * @param[in] q I/O queue
+ *
+ * @retval Cache instance
+ */
+ocf_cache_t ocf_queue_get_cache(ocf_queue_t q);
+
+#endif
diff --git a/src/spdk/ocf/inc/ocf_stats.h b/src/spdk/ocf/inc/ocf_stats.h
new file mode 100644
index 000000000..b326c7409
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_stats.h
@@ -0,0 +1,239 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+/**
+ * @file
+ * @brief OCF API for updating and reseting statistics
+ *
+ * This file contains routines pertaining to manipulation of OCF IO statistics.
+ */
+
+#ifndef __OCF_STATS_H__
+#define __OCF_STATS_H__
+
+/**
+ * Entire row of statistcs
+ */
+struct ocf_stat {
+ /** Value */
+ uint64_t value;
+ /** percent x100 */
+ uint64_t fraction;
+};
+
+/**
+ * @brief Usage statistics in 4 KiB unit
+ *
+ * An example of presenting statistics:
+ * <pre>
+ * ╔══════════════════╤══════════╤═══════╤═════════════╗
+ * ║ Usage statistics │ Count │ % │ Units ║
+ * ╠══════════════════╪══════════╪═══════╪═════════════╣
+ * ║ Occupancy │ 20 │ 50.0 │ 4KiB blocks ║
+ * ║ Free │ 20 │ 50.0 │ 4KiB blocks ║
+ * ║ Clean │ 15 │ 75.0 │ 4KiB blocks ║
+ * ║ Dirty │ 5 │ 25.0 │ 4KiB blocks ║
+ * ╚══════════════════╧══════════╧═══════╧═════════════╝
+ * </pre>
+ */
+struct ocf_stats_usage {
+ struct ocf_stat occupancy;
+ struct ocf_stat free;
+ struct ocf_stat clean;
+ struct ocf_stat dirty;
+};
+
+/**
+ * @brief Requests statistcs
+ *
+ * An example of presenting statistics:
+ * <pre>
+ * ╔══════════════════════╤═══════╤═══════╤══════════╗
+ * ║ Request statistics │ Count │ % │ Units ║
+ * ╠══════════════════════╪═══════╪═══════╪══════════╣
+ * ║ Read hits │ 10 │ 4.5 │ Requests ║
+ * ║ Read partial misses │ 1 │ 0.5 │ Requests ║
+ * ║ Read full misses │ 211 │ 95.0 │ Requests ║
+ * ║ Read total │ 222 │ 100.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Write hits │ 0 │ 0.0 │ Requests ║
+ * ║ Write partial misses │ 0 │ 0.0 │ Requests ║
+ * ║ Write full misses │ 0 │ 0.0 │ Requests ║
+ * ║ Write total │ 0 │ 0.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Pass-Through reads │ 0 │ 0.0 │ Requests ║
+ * ║ Pass-Through writes │ 0 │ 0.0 │ Requests ║
+ * ║ Serviced requests │ 222 │ 100.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Total requests │ 222 │ 100.0 │ Requests ║
+ * ╚══════════════════════╧═══════╧═══════╧══════════╝
+ * </pre>
+ */
+struct ocf_stats_requests {
+ struct ocf_stat rd_hits;
+ struct ocf_stat rd_partial_misses;
+ struct ocf_stat rd_full_misses;
+ struct ocf_stat rd_total;
+ struct ocf_stat wr_hits;
+ struct ocf_stat wr_partial_misses;
+ struct ocf_stat wr_full_misses;
+ struct ocf_stat wr_total;
+ struct ocf_stat rd_pt;
+ struct ocf_stat wr_pt;
+ struct ocf_stat serviced;
+ struct ocf_stat total;
+};
+
+/**
+ * @brief Block statistics
+ *
+ * An example of presenting statistics:
+ * <pre>
+ * ╔════════════════════════════════════╤═══════╤═══════╤═════════════╗
+ * ║ Block statistics │ Count │ % │ Units ║
+ * ╠════════════════════════════════════╪═══════╪═══════╪═════════════╣
+ * ║ Reads from core volume(s) │ 426 │ 100.0 │ 4KiB blocks ║
+ * ║ Writes to core volume(s) │ 0 │ 0.0 │ 4KiB blocks ║
+ * ║ Total to/from core volume (s) │ 426 │ 100.0 │ 4KiB blocks ║
+ * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
+ * ║ Reads from cache volume │ 13 │ 3.0 │ 4KiB blocks ║
+ * ║ Writes to cache volume │ 426 │ 97.0 │ 4KiB blocks ║
+ * ║ Total to/from cache volume │ 439 │ 100.0 │ 4KiB blocks ║
+ * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
+ * ║ Reads from core(s) │ 439 │ 100.0 │ 4KiB blocks ║
+ * ║ Writes to core(s) │ 0 │ 0.0 │ 4KiB blocks ║
+ * ║ Total to/from core(s) │ 439 │ 100.0 │ 4KiB blocks ║
+ * ╚════════════════════════════════════╧═══════╧═══════╧═════════════╝
+ * </pre>
+ */
+struct ocf_stats_blocks {
+ struct ocf_stat core_volume_rd;
+ struct ocf_stat core_volume_wr;
+ struct ocf_stat core_volume_total;
+ struct ocf_stat cache_volume_rd;
+ struct ocf_stat cache_volume_wr;
+ struct ocf_stat cache_volume_total;
+ struct ocf_stat volume_rd;
+ struct ocf_stat volume_wr;
+ struct ocf_stat volume_total;
+};
+
+/**
+ * @brief Errors statistics
+ *
+ * An example of presenting statistics:
+ * <pre>
+ * ╔════════════════════╤═══════╤═════╤══════════╗
+ * ║ Error statistics │ Count │ % │ Units ║
+ * ╠════════════════════╪═══════╪═════╪══════════╣
+ * ║ Cache read errors │ 0 │ 0.0 │ Requests ║
+ * ║ Cache write errors │ 0 │ 0.0 │ Requests ║
+ * ║ Cache total errors │ 0 │ 0.0 │ Requests ║
+ * ╟────────────────────┼───────┼─────┼──────────╢
+ * ║ Core read errors │ 0 │ 0.0 │ Requests ║
+ * ║ Core write errors │ 0 │ 0.0 │ Requests ║
+ * ║ Core total errors │ 0 │ 0.0 │ Requests ║
+ * ╟────────────────────┼───────┼─────┼──────────╢
+ * ║ Total errors │ 0 │ 0.0 │ Requests ║
+ * ╚════════════════════╧═══════╧═════╧══════════╝
+ * </pre>
+ */
+struct ocf_stats_errors {
+ struct ocf_stat core_volume_rd;
+ struct ocf_stat core_volume_wr;
+ struct ocf_stat core_volume_total;
+ struct ocf_stat cache_volume_rd;
+ struct ocf_stat cache_volume_wr;
+ struct ocf_stat cache_volume_total;
+ struct ocf_stat total;
+};
+
+/**
+ * @param Collect statistics for given cache
+ *
+ * @param cache Cache instance for which statistics will be collected
+ * @param usage Usage statistics
+ * @param req Request statistics
+ * @param blocks Blocks statistics
+ * @param errors Errors statistics
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_stats_collect_cache(ocf_cache_t cache,
+ struct ocf_stats_usage *usage,
+ struct ocf_stats_requests *req,
+ struct ocf_stats_blocks *blocks,
+ struct ocf_stats_errors *errors);
+
+/**
+ * @param Collect statistics for given core
+ *
+ * @param core Core for which statistics will be collected
+ * @param usage Usage statistics
+ * @param req Request statistics
+ * @param blocks Blocks statistics
+ * @param errors Errors statistics
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_stats_collect_core(ocf_core_t core,
+ struct ocf_stats_usage *usage,
+ struct ocf_stats_requests *req,
+ struct ocf_stats_blocks *blocks,
+ struct ocf_stats_errors *errors);
+
+/**
+ * @param Collect statistics for given ioclass
+ *
+ * @param core Core handle for which statistics will be collected
+ * @param part_id Ioclass id for which statistics will be collected
+ * @param usage Usage statistics
+ * @param req Request statistics
+ * @param blocks Blocks statistics
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_stats_collect_part_core(ocf_core_t core, ocf_part_id_t part_id,
+ struct ocf_stats_usage *usage, struct ocf_stats_requests *req,
+ struct ocf_stats_blocks *blocks);
+
+/**
+ * @param Collect statistics for given ioclass
+ *
+ * @param cache Cache instance for which statistics will be collected
+ * @param part_id Ioclass id for which statistics will be collected
+ * @param usage Usage statistics
+ * @param req Request statistics
+ * @param blocks Blocks statistics
+ *
+ * @retval 0 Success
+ * @retval Non-zero Error
+ */
+int ocf_stats_collect_part_cache(ocf_cache_t cache, ocf_part_id_t part_id,
+ struct ocf_stats_usage *usage, struct ocf_stats_requests *req,
+ struct ocf_stats_blocks *blocks);
+
+/**
+ * @brief Initialize or reset core statistics
+ *
+ * Initialize or reset counters used for statistics.
+ *
+ * @param[in] core Core handle
+ */
+void ocf_core_stats_initialize(ocf_core_t core);
+
+/**
+ * @brief Initialize or reset statistics of all cores in cache
+ *
+ * Initialize or reset counters used for statistics.
+ *
+ * @param[in] cache Cache handle
+ */
+void ocf_core_stats_initialize_all(ocf_cache_t cache);
+
+#endif /* __OCF_STATS_H__ */
diff --git a/src/spdk/ocf/inc/ocf_trace.h b/src/spdk/ocf/inc/ocf_trace.h
new file mode 100644
index 000000000..4a0f61390
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_trace.h
@@ -0,0 +1,185 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_TRACE_H__
+#define __OCF_TRACE_H__
+
+#include "ocf_def.h"
+#include "ocf_types.h"
+
+typedef uint64_t log_sid_t;
+
+#define OCF_EVENT_VERSION 1
+#define OCF_TRACING_STOP 1
+
+/**
+ * @brief OCF trace (event) type
+ */
+typedef enum {
+ /** IO trace description, this event is pushed first to indicate version
+ * of traces, number of cores and provides details about cache */
+ ocf_event_type_cache_desc,
+
+ /** Event describing ocf core */
+ ocf_event_type_core_desc,
+
+ /** IO */
+ ocf_event_type_io,
+
+ /** IO completion */
+ ocf_event_type_io_cmpl,
+
+ /** IO in file domain */
+ ocf_event_type_io_file,
+} ocf_event_type;
+
+/**
+ * @brief Generic OCF trace event
+ */
+struct ocf_event_hdr {
+ /** Event sequence ID */
+ log_sid_t sid;
+
+ /** Time stamp */
+ uint64_t timestamp;
+
+ /** Trace event type */
+ ocf_event_type type;
+
+ /** Size of this event */
+ uint32_t size;
+};
+
+/**
+ * @brief Cache trace description
+*/
+struct ocf_event_cache_desc {
+ /** Event header */
+ struct ocf_event_hdr hdr;
+
+ /** Cache name */
+ const char *name;
+
+ /** Cache line size */
+ ocf_cache_line_size_t cache_line_size;
+
+ /** Cache mode */
+ ocf_cache_mode_t cache_mode;
+
+ /** Cache size in bytes*/
+ uint64_t cache_size;
+
+ /** Number of cores */
+ uint32_t cores_no;
+
+ /** Trace version */
+ uint32_t version;
+};
+
+/**
+ * @brief Core trace description
+*/
+struct ocf_event_core_desc {
+ /** Event header */
+ struct ocf_event_hdr hdr;
+
+ /** Core name */
+ const char *name;
+
+ /** Core size in bytes */
+ uint64_t core_size;
+};
+
+/** @brief IO operation */
+typedef enum {
+ /** Read */
+ ocf_event_operation_rd = 'R',
+
+ /** Write */
+ ocf_event_operation_wr = 'W',
+
+ /** Flush */
+ ocf_event_operation_flush = 'F',
+
+ /** Discard */
+ ocf_event_operation_discard = 'D',
+} ocf_event_operation_t;
+
+/**
+ * @brief IO trace event
+ */
+struct ocf_event_io {
+ /** Trace event header */
+ struct ocf_event_hdr hdr;
+
+ /** Address of IO in bytes */
+ uint64_t addr;
+
+ /** Size of IO in bytes */
+ uint32_t len;
+
+ /** IO class of IO */
+ uint32_t io_class;
+
+ /** Core name */
+ const char *core_name;
+
+ /** Operation type: read, write, trim or flush **/
+ ocf_event_operation_t operation;
+};
+
+/**
+ * @brief IO completion event
+ */
+struct ocf_event_io_cmpl {
+ /** Trace event header */
+ struct ocf_event_hdr hdr;
+
+ /** Reference event sequence ID */
+ log_sid_t rsid;
+
+ /** Was IO a cache hit or miss */
+ bool is_hit;
+};
+
+
+/** @brief Push log callback.
+ *
+ * @param[in] cache OCF cache
+ * @param[in] trace_ctx Tracing context
+ * @param[in] queue Queue handle
+ * @param[out] trace Event log
+ * @param[out] size Size of event log
+ *
+ * @return 0 If pushing trace succeeded
+ * @return Non-zero error
+ */
+typedef void (*ocf_trace_callback_t)(ocf_cache_t cache, void *trace_ctx,
+ ocf_queue_t queue, const void* trace, const uint32_t size);
+
+/**
+ * @brief Start tracing
+ *
+ * @param[in] cache OCF cache
+ * @param[in] trace_ctx Tracing context
+ * @param[in] trace_callback Callback used for pushing logs
+ *
+ * @retval 0 Tracing started successfully
+ * @retval Non-zero Error
+ */
+int ocf_mngt_start_trace(ocf_cache_t cache, void *trace_ctx,
+ ocf_trace_callback_t trace_callback);
+
+/**
+ * @brief Stop tracing
+ *
+ * @param[in] cache OCF cache
+ *
+ * @retval 0 Tracing stopped successfully
+ * @retval Non-zero Error
+ */
+int ocf_mngt_stop_trace(ocf_cache_t cache);
+
+#endif /* __OCF_TRACE_H__ */
diff --git a/src/spdk/ocf/inc/ocf_types.h b/src/spdk/ocf/inc/ocf_types.h
new file mode 100644
index 000000000..ead3b0d06
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_types.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+/**
+ * @file
+ * @brief OCF types
+ */
+#ifndef __OCF_TYPES_H_
+#define __OCF_TYPES_H_
+
+#include "ocf_env_headers.h"
+
+/**
+ * @brief cache line type (by default designated as 32 bit unsigned integer)
+ */
+typedef uint32_t ocf_cache_line_t;
+
+/**
+ * @brief core id type (by default designated as 16 bit unsigned integer)
+ */
+typedef uint16_t ocf_core_id_t;
+
+/**
+ * @brief core sequence number type (by default designated as 16 bit unsigned integer)
+ */
+typedef uint16_t ocf_seq_no_t;
+
+/**
+ * @brief partition id type (by default designated as 16 bit unsigned integer)
+ */
+typedef uint16_t ocf_part_id_t;
+
+/**
+ * @brief handle to object designating ocf context
+ */
+typedef struct ocf_ctx *ocf_ctx_t;
+
+struct ocf_cache;
+/**
+ * @brief handle to object designating ocf cache device
+ */
+typedef struct ocf_cache *ocf_cache_t;
+
+struct ocf_core;
+/**
+ * @brief handle to object designating ocf core object
+ */
+typedef struct ocf_core *ocf_core_t;
+
+struct ocf_volume;
+/**
+ * @brief handle to object designating ocf volume
+ */
+typedef struct ocf_volume *ocf_volume_t;
+
+
+struct ocf_volume_type;
+/**
+ * @brief handle to volume type
+ */
+typedef struct ocf_volume_type *ocf_volume_type_t;
+
+/**
+ * @brief handle to volume uuid
+ */
+typedef struct ocf_volume_uuid *ocf_uuid_t;
+
+/**
+ * @brief handle to object designating ocf context object
+ */
+typedef void ctx_data_t;
+
+/**
+ * @brief handle to I/O queue
+ */
+typedef struct ocf_queue *ocf_queue_t;
+
+/**
+ * @brief handle to cleaner
+ */
+typedef struct ocf_cleaner *ocf_cleaner_t;
+
+/**
+ * @brief handle to metadata_updater
+ */
+typedef struct ocf_metadata_updater *ocf_metadata_updater_t;
+
+/**
+ * @brief handle to logger
+ */
+typedef struct ocf_logger *ocf_logger_t;
+
+#endif
diff --git a/src/spdk/ocf/inc/ocf_volume.h b/src/spdk/ocf/inc/ocf_volume.h
new file mode 100644
index 000000000..ca3f9c238
--- /dev/null
+++ b/src/spdk/ocf/inc/ocf_volume.h
@@ -0,0 +1,338 @@
+/*
+ * Copyright(c) 2012-2018 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_VOLUME_H__
+#define __OCF_VOLUME_H__
+
+/**
+ * @file
+ * @brief OCF volume API
+ */
+
+#include "ocf_types.h"
+#include "ocf_env.h"
+#include "ocf/ocf_err.h"
+
+struct ocf_io;
+
+/**
+ * @brief OCF volume UUID maximum allowed size
+ */
+#define OCF_VOLUME_UUID_MAX_SIZE (4096UL - sizeof(uint32_t))
+
+/**
+ * @brief OCF volume UUID
+ */
+struct ocf_volume_uuid {
+ size_t size;
+ /*!< UUID data size */
+
+ void *data;
+ /*!< UUID data content */
+};
+
+/**
+ * @brief This structure describes volume capabilities
+ */
+struct ocf_volume_caps {
+ uint32_t atomic_writes : 1;
+ /*!< Volume supports atomic writes */
+};
+
+/**
+ * @brief OCF volume interface declaration
+ */
+struct ocf_volume_ops {
+ /**
+ * @brief Submit IO on this volume
+ *
+ * @param[in] io IO to be submitted
+ */
+ void (*submit_io)(struct ocf_io *io);
+
+ /**
+ * @brief Submit IO with flush command
+ *
+ * @param[in] io IO to be submitted
+ */
+ void (*submit_flush)(struct ocf_io *io);
+
+ /**
+ * @brief Submit IO with metadata
+ *
+ * @param[in] io IO to be submitted
+ */
+ void (*submit_metadata)(struct ocf_io *io);
+
+ /**
+ * @brief Submit IO with discard command
+ *
+ * @param[in] io IO to be submitted
+ */
+ void (*submit_discard)(struct ocf_io *io);
+
+ /**
+ * @brief Submit operation to write zeroes to target address (including
+ * metadata extended LBAs in atomic mode)
+ *
+ * @param[in] io IO description (addr, size)
+ */
+ void (*submit_write_zeroes)(struct ocf_io *io);
+
+ /**
+ * @brief Open volume
+ *
+ * @note This function performs volume initialization and should
+ * be called before any other operation on volume
+ *
+ * @param[in] volume Volume
+ * @param[in] volume_params optional volume parameters, opaque to OCF
+ *
+ * @return Zero on success, otherwise error code
+ */
+ int (*open)(ocf_volume_t volume, void *volume_params);
+
+ /**
+ * @brief Close volume
+ *
+ * @param[in] volume Volume
+ */
+ void (*close)(ocf_volume_t volume);
+
+ /**
+ * @brief Get maximum io size
+ *
+ * @param[in] volume Volume
+ *
+ * @return Maximum io size in bytes
+ */
+ unsigned int (*get_max_io_size)(ocf_volume_t volume);
+
+ /**
+ * @brief Get volume length
+ *
+ * @param[in] volume Volume
+ *
+ * @return Volume lenght in bytes
+ */
+ uint64_t (*get_length)(ocf_volume_t volume);
+};
+
+/**
+ * @brief This structure describes volume properties
+ */
+struct ocf_volume_properties {
+ const char *name;
+ /*!< The name of volume operations */
+
+ uint32_t io_priv_size;
+ /*!< Size of io private context structure */
+
+ uint32_t volume_priv_size;
+ /*!< Size of volume private context structure */
+
+ struct ocf_volume_caps caps;
+ /*!< Volume capabilities */
+
+ struct ocf_volume_ops ops;
+ /*!< Volume operations */
+
+ struct ocf_io_ops io_ops;
+ /*!< IO operations */
+
+ void (*deinit)(void);
+ /*!< Deinitialize volume type */
+};
+
+/**
+ * @brief Initialize UUID from string
+ *
+ * @param[in] uuid UUID to be initialized
+ * @param[in] str NULL-terminated string
+ *
+ * @return Zero when success, othewise error
+ */
+static inline int ocf_uuid_set_str(ocf_uuid_t uuid, char *str)
+{
+ size_t len = env_strnlen(str, OCF_VOLUME_UUID_MAX_SIZE);
+
+ if (len >= OCF_VOLUME_UUID_MAX_SIZE)
+ return -OCF_ERR_INVAL;
+
+ uuid->data = str;
+ uuid->size = len + 1;
+
+ return 0;
+}
+
+/**
+ * @brief Obtain string from UUID
+ * @param[in] uuid pointer to UUID
+ * @return String contained within UUID
+ */
+static inline const char *ocf_uuid_to_str(const struct ocf_volume_uuid *uuid)
+{
+ return (const char *)uuid->data;
+}
+
+/**
+ * @brief Initialize volume
+ *
+ * @param[in] volume volume handle
+ * @param[in] type cache/core volume type
+ * @param[in] uuid OCF volume UUID
+ * @param[in] uuid_copy crate copy of uuid data
+ *
+ * @return Zero when success, othewise error
+ */
+int ocf_volume_init(ocf_volume_t volume, ocf_volume_type_t type,
+ struct ocf_volume_uuid *uuid, bool uuid_copy);
+
+/**
+ * @brief Deinitialize volume
+ *
+ * @param[in] volume volume handle
+ */
+void ocf_volume_deinit(ocf_volume_t volume);
+
+/**
+ * @brief Allocate and initialize volume
+ *
+ * @param[out] volume pointer to volume handle
+ * @param[in] type cache/core volume type
+ * @param[in] uuid OCF volume UUID
+ *
+ * @return Zero when success, othewise en error
+ */
+int ocf_volume_create(ocf_volume_t *volume, ocf_volume_type_t type,
+ struct ocf_volume_uuid *uuid);
+
+/**
+ * @brief Deinitialize and free volume
+ *
+ * @param[in] volume volume handle
+ */
+void ocf_volume_destroy(ocf_volume_t volume);
+
+/**
+ * @brief Get volume type
+ *
+ * @param[in] volume Volume
+ *
+ * @return Volume type
+ */
+ocf_volume_type_t ocf_volume_get_type(ocf_volume_t volume);
+
+/**
+ * @brief Get volume UUID
+ *
+ * @param[in] volume Volume
+ *
+ * @return UUID of volume
+ */
+const struct ocf_volume_uuid *ocf_volume_get_uuid(ocf_volume_t volume);
+
+/**
+ * @brief Get private context of volume
+ *
+ * @param[in] volume Volume
+ *
+ * @return Volume private context
+ */
+void *ocf_volume_get_priv(ocf_volume_t volume);
+
+/**
+ * @brief Get cache handle for given volume
+ *
+ * @param volume volume handle
+ *
+ * @return Handle to cache for which volume belongs to
+ */
+ocf_cache_t ocf_volume_get_cache(ocf_volume_t volume);
+
+/**
+ * @brief Check if volume supports atomic mode
+ *
+ * @param[in] volume Volume
+ *
+ * @return Non-zero value if volume is atomic, otherwise zero
+ */
+int ocf_volume_is_atomic(ocf_volume_t volume);
+
+/**
+ * @brief Allocate new io
+ *
+ * @param[in] volume Volume
+ * @param[in] queue IO queue handle
+ * @param[in] addr OCF IO destination address
+ * @param[in] bytes OCF IO size in bytes
+ * @param[in] dir OCF IO direction
+ * @param[in] io_class OCF IO destination class
+ * @param[in] flags OCF IO flags
+ *
+ * @return ocf_io on success atomic, otherwise NULL
+ */
+struct ocf_io *ocf_volume_new_io(ocf_volume_t volume, ocf_queue_t queue,
+ uint64_t addr, uint32_t bytes, uint32_t dir,
+ uint32_t io_class, uint64_t flags);
+
+
+/**
+ * @brief Submit io to volume
+ *
+ * @param[in] io IO
+ */
+void ocf_volume_submit_io(struct ocf_io *io);
+
+/**
+ * @brief Submit flush to volume
+ *
+ * @param[in] io IO
+ */
+void ocf_volume_submit_flush(struct ocf_io *io);
+
+/**
+ * @brief Submit discard to volume
+ *
+ * @param[in] io IO
+ */
+void ocf_volume_submit_discard(struct ocf_io *io);
+
+/**
+ * @brief Open volume
+ *
+ * @param[in] volume Volume
+ * @param[in] volume_params Opaque volume params
+ *
+ * @return Zero when success, othewise en error
+ */
+int ocf_volume_open(ocf_volume_t volume, void *volume_params);
+
+/**
+ * @brief Get volume max io size
+ *
+ * @param[in] volume Volume
+ */
+void ocf_volume_close(ocf_volume_t volume);
+
+/**
+ * @brief Get volume max io size
+ *
+ * @param[in] volume Volume
+ *
+ * @return Volume max io size in bytes
+ */
+unsigned int ocf_volume_get_max_io_size(ocf_volume_t volume);
+
+/**
+ * @brief Get volume length
+ *
+ * @param[in] volume Volume
+ *
+ * @return Length of volume in bytes
+ */
+uint64_t ocf_volume_get_length(ocf_volume_t volume);
+
+#endif /* __OCF_VOLUME_H__ */
diff --git a/src/spdk/ocf/inc/promotion/nhit.h b/src/spdk/ocf/inc/promotion/nhit.h
new file mode 100644
index 000000000..32f4dac63
--- /dev/null
+++ b/src/spdk/ocf/inc/promotion/nhit.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright(c) 2019 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __OCF_PROMOTION_NHIT_H__
+#define __OCF_PROMOTION_NHIT_H__
+
+enum ocf_nhit_param {
+ ocf_nhit_insertion_threshold,
+ ocf_nhit_trigger_threshold,
+ ocf_nhit_param_max
+};
+
+#define OCF_NHIT_MIN_THRESHOLD 2
+#define OCF_NHIT_MAX_THRESHOLD 1000
+#define OCF_NHIT_THRESHOLD_DEFAULT 3
+
+#define OCF_NHIT_MIN_TRIGGER 0
+#define OCF_NHIT_MAX_TRIGGER 100
+#define OCF_NHIT_TRIGGER_DEFAULT 80
+
+#endif /* __OCF_PROMOTION_NHIT_H__ */