2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
13 * @brief OCF definitions
17 * @name OCF cache definitions
20 * Minimum value of a valid cache ID
22 #define OCF_CACHE_ID_MIN 1
24 * Maximum value of a valid cache ID
26 #define OCF_CACHE_ID_MAX 16384
28 * Invalid value of cache id
30 #define OCF_CACHE_ID_INVALID 0
32 * Minimum cache size in bytes
34 #define OCF_CACHE_SIZE_MIN (20 * MiB)
38 #define OCF_CACHE_NAME_SIZE 32
40 * Value to turn off fallback pass through
42 #define OCF_CACHE_FALLBACK_PT_INACTIVE 0
44 * Minimum value of io error threshold
46 #define OCF_CACHE_FALLBACK_PT_MIN_ERROR_THRESHOLD \
47 OCF_CACHE_FALLBACK_PT_INACTIVE
49 * Maximum value of io error threshold
51 #define OCF_CACHE_FALLBACK_PT_MAX_ERROR_THRESHOLD 1000000
57 * @name OCF cores definitions
60 * Maximum numbers of cores per cache instance
62 #define OCF_CORE_MAX OCF_CONFIG_MAX_CORES
64 * Minimum value of a valid core ID
66 #define OCF_CORE_ID_MIN 0
68 * Maximum value of a valid core ID
70 #define OCF_CORE_ID_MAX (OCF_CORE_MAX - 1)
72 * Invalid value of core id
74 #define OCF_CORE_ID_INVALID OCF_CORE_MAX
78 #define OCF_CORE_NAME_SIZE 32
80 * Minimum value of valid core sequence number
82 #define OCF_SEQ_NO_MIN 1
84 * Maximum value of a valid core sequence number
86 #define OCF_SEQ_NO_MAX (65535UL)
88 * Invalid value of core sequence number
90 #define OCF_SEQ_NO_INVALID 0
96 * @name Miscellaneous defines
99 #define KiB (1ULL << 10)
100 #define MiB (1ULL << 20)
101 #define GiB (1ULL << 30)
103 #if OCF_CONFIG_DEBUG_STATS == 1
104 /** Macro which indicates that extended debug statistics shall be on*/
105 #define OCF_DEBUG_STATS
112 * This Enumerator describes OCF cache instance state
115 ocf_cache_state_running
= 0, //!< ocf_cache_state_running
116 /*!< OCF is currently running */
118 ocf_cache_state_stopping
= 1, //!< ocf_cache_state_stopping
119 /*!< OCF cache instance is stopping */
121 ocf_cache_state_initializing
= 2, //!< ocf_cache_state_initializing
122 /*!< OCF cache instance during initialization */
124 ocf_cache_state_incomplete
= 3, //!< ocf_cache_state_incomplete
125 /*!< OCF cache has at least one inactive core */
127 ocf_cache_state_max
//!< ocf_cache_state_max
128 /*!< Stopper of cache state enumerator */
132 * This Enumerator describes OCF core instance state
135 ocf_core_state_active
= 0,
136 /*!< Core is active */
138 ocf_core_state_inactive
,
139 /*!< Core is inactive (not attached) */
142 /*!< Stopper of core state enumerator */
147 * OCF supported cache modes
150 ocf_cache_mode_wt
= 0,
151 /*!< Write-through cache mode */
154 /*!< Write-back cache mode */
157 /*!< Write-around cache mode */
160 /*!< Pass-through cache mode */
163 /*!< Write invalidate cache mode */
166 /*!< Stopper of cache mode enumerator */
168 ocf_cache_mode_default
= ocf_cache_mode_wt
,
169 /*!< Default cache mode */
171 ocf_cache_mode_none
= -1,
172 /*!< Current cache mode of given cache instance */
176 ocf_seq_cutoff_policy_always
= 0,
177 /*!< Sequential cutoff always on */
179 ocf_seq_cutoff_policy_full
,
180 /*!< Sequential cutoff when occupancy is 100% */
182 ocf_seq_cutoff_policy_never
,
183 /*!< Sequential cutoff disabled */
185 ocf_seq_cutoff_policy_max
,
186 /*!< Stopper of sequential cutoff policy enumerator */
188 ocf_seq_cutoff_policy_default
= ocf_seq_cutoff_policy_full
,
189 /*!< Default sequential cutoff policy*/
190 } ocf_seq_cutoff_policy
;
193 * OCF supported eviction types
196 ocf_eviction_lru
= 0,
197 /*!< Last recently used eviction policy */
200 /*!< Stopper of enumerator */
202 ocf_eviction_default
= ocf_eviction_lru
,
203 /*!< Default eviction policy */
207 * OCF supported Write-Back cleaning policies type
210 ocf_cleaning_nop
= 0,
211 /*!< Cleaning won't happen in background. Only on eviction or
216 /*!< Approximately recently used. Cleaning thread in the
217 * background enabled which cleans dirty data during IO
222 /*!< Cleaning algorithm attempts to reduce core device seek
223 * distance. Cleaning thread runs concurrently with I/O.
227 /*!< Stopper of enumerator */
229 ocf_cleaning_default
= ocf_cleaning_alru
,
230 /*!< Default cleaning policy type */
234 * OCF supported cache line sizes in bytes
237 ocf_cache_line_size_4
= 4 * KiB
,
240 ocf_cache_line_size_8
= 8 * KiB
,
243 ocf_cache_line_size_16
= 16 * KiB
,
246 ocf_cache_line_size_32
= 32 * KiB
,
249 ocf_cache_line_size_64
= 64 * KiB
,
252 ocf_cache_line_size_default
= ocf_cache_line_size_4
,
253 /*!< Default cache line size */
255 ocf_cache_line_size_min
= ocf_cache_line_size_4
,
256 /*!< Minimum cache line size */
258 ocf_cache_line_size_max
= ocf_cache_line_size_64
,
259 /*!< Maximal cache line size */
261 ocf_cache_line_size_inf
= ~0ULL,
262 /*!< Force enum to be 64-bit */
263 } ocf_cache_line_size_t
;
269 ocf_metadata_layout_striping
= 0,
270 ocf_metadata_layout_seq
= 1,
271 ocf_metadata_layout_max
,
272 ocf_metadata_layout_default
= ocf_metadata_layout_striping
273 } ocf_metadata_layout_t
;
276 * @name OCF IO class definitions
279 * Maximum numbers of IO classes per cache instance
281 #define OCF_IO_CLASS_MAX OCF_CONFIG_MAX_IO_CLASSES
283 * Minimum value of a valid IO class ID
285 #define OCF_IO_CLASS_ID_MIN 0
287 * Maximum value of a valid IO class ID
289 #define OCF_IO_CLASS_ID_MAX (OCF_IO_CLASS_MAX - 1)
291 * Invalid value of IO class id
293 #define OCF_IO_CLASS_INVALID OCF_IO_CLASS_MAX
295 /** Maximum size of the IO class name */
296 #define OCF_IO_CLASS_NAME_MAX 1024
298 /** IO class priority which indicates pinning */
299 #define OCF_IO_CLASS_PRIO_PINNED -1
301 /** The highest IO class priority */
302 #define OCF_IO_CLASS_PRIO_HIGHEST 0
304 /** The lowest IO class priority */
305 #define OCF_IO_CLASS_PRIO_LOWEST 255
307 /** Default IO class priority */
308 #define OCF_IO_CLASS_PRIO_DEFAULT OCF_IO_CLASS_PRIO_LOWEST
314 * @name I/O operations
324 * @name OCF cleaner definitions
327 #define OCF_CLEANER_DISABLE ~0U
332 #define MAX_TRIM_RQ_SIZE (1 * MiB)
334 #endif /* __OCF_DEF_H__ */