]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/inc/ocf_def.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / inc / ocf_def.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6
7 #ifndef __OCF_DEF_H__
8 #define __OCF_DEF_H__
9
10 #include "ocf_cfg.h"
11 /**
12 * @file
13 * @brief OCF definitions
14 */
15
16 /**
17 * @name OCF cache definitions
18 */
19 /**
20 * Minimum value of a valid cache ID
21 */
22 #define OCF_CACHE_ID_MIN 1
23 /**
24 * Maximum value of a valid cache ID
25 */
26 #define OCF_CACHE_ID_MAX 16384
27 /**
28 * Invalid value of cache id
29 */
30 #define OCF_CACHE_ID_INVALID 0
31 /**
32 * Minimum cache size in bytes
33 */
34 #define OCF_CACHE_SIZE_MIN (20 * MiB)
35 /**
36 * Size of cache name
37 */
38 #define OCF_CACHE_NAME_SIZE 32
39 /**
40 * Value to turn off fallback pass through
41 */
42 #define OCF_CACHE_FALLBACK_PT_INACTIVE 0
43 /**
44 * Minimum value of io error threshold
45 */
46 #define OCF_CACHE_FALLBACK_PT_MIN_ERROR_THRESHOLD \
47 OCF_CACHE_FALLBACK_PT_INACTIVE
48 /**
49 * Maximum value of io error threshold
50 */
51 #define OCF_CACHE_FALLBACK_PT_MAX_ERROR_THRESHOLD 1000000
52 /**
53 * @}
54 */
55
56 /**
57 * @name OCF cores definitions
58 */
59 /**
60 * Maximum numbers of cores per cache instance
61 */
62 #define OCF_CORE_MAX OCF_CONFIG_MAX_CORES
63 /**
64 * Minimum value of a valid core ID
65 */
66 #define OCF_CORE_ID_MIN 0
67 /**
68 * Maximum value of a valid core ID
69 */
70 #define OCF_CORE_ID_MAX (OCF_CORE_MAX - 1)
71 /**
72 * Invalid value of core id
73 */
74 #define OCF_CORE_ID_INVALID OCF_CORE_MAX
75 /**
76 * Size of core name
77 */
78 #define OCF_CORE_NAME_SIZE 32
79 /**
80 * Minimum value of valid core sequence number
81 */
82 #define OCF_SEQ_NO_MIN 1
83 /**
84 * Maximum value of a valid core sequence number
85 */
86 #define OCF_SEQ_NO_MAX (65535UL)
87 /*
88 * Invalid value of core sequence number
89 */
90 #define OCF_SEQ_NO_INVALID 0
91 /**
92 * @}
93 */
94
95 /**
96 * @name Miscellaneous defines
97 * @{
98 */
99 #define KiB (1ULL << 10)
100 #define MiB (1ULL << 20)
101 #define GiB (1ULL << 30)
102
103 #if OCF_CONFIG_DEBUG_STATS == 1
104 /** Macro which indicates that extended debug statistics shall be on*/
105 #define OCF_DEBUG_STATS
106 #endif
107 /**
108 * @}
109 */
110
111 /**
112 * This Enumerator describes OCF cache instance state
113 */
114 typedef enum {
115 ocf_cache_state_running = 0, //!< ocf_cache_state_running
116 /*!< OCF is currently running */
117
118 ocf_cache_state_stopping = 1, //!< ocf_cache_state_stopping
119 /*!< OCF cache instance is stopping */
120
121 ocf_cache_state_initializing = 2, //!< ocf_cache_state_initializing
122 /*!< OCF cache instance during initialization */
123
124 ocf_cache_state_incomplete = 3, //!< ocf_cache_state_incomplete
125 /*!< OCF cache has at least one inactive core */
126
127 ocf_cache_state_max //!< ocf_cache_state_max
128 /*!< Stopper of cache state enumerator */
129 } ocf_cache_state_t;
130
131 /**
132 * This Enumerator describes OCF core instance state
133 */
134 typedef enum {
135 ocf_core_state_active = 0,
136 /*!< Core is active */
137
138 ocf_core_state_inactive,
139 /*!< Core is inactive (not attached) */
140
141 ocf_core_state_max,
142 /*!< Stopper of core state enumerator */
143 } ocf_core_state_t;
144
145
146 /**
147 * OCF supported cache modes
148 */
149 typedef enum {
150 ocf_cache_mode_wt = 0,
151 /*!< Write-through cache mode */
152
153 ocf_cache_mode_wb,
154 /*!< Write-back cache mode */
155
156 ocf_cache_mode_wa,
157 /*!< Write-around cache mode */
158
159 ocf_cache_mode_pt,
160 /*!< Pass-through cache mode */
161
162 ocf_cache_mode_wi,
163 /*!< Write invalidate cache mode */
164
165 ocf_cache_mode_max,
166 /*!< Stopper of cache mode enumerator */
167
168 ocf_cache_mode_default = ocf_cache_mode_wt,
169 /*!< Default cache mode */
170
171 ocf_cache_mode_none = -1,
172 /*!< Current cache mode of given cache instance */
173 } ocf_cache_mode_t;
174
175 typedef enum {
176 ocf_seq_cutoff_policy_always = 0,
177 /*!< Sequential cutoff always on */
178
179 ocf_seq_cutoff_policy_full,
180 /*!< Sequential cutoff when occupancy is 100% */
181
182 ocf_seq_cutoff_policy_never,
183 /*!< Sequential cutoff disabled */
184
185 ocf_seq_cutoff_policy_max,
186 /*!< Stopper of sequential cutoff policy enumerator */
187
188 ocf_seq_cutoff_policy_default = ocf_seq_cutoff_policy_full,
189 /*!< Default sequential cutoff policy*/
190 } ocf_seq_cutoff_policy;
191
192 /**
193 * OCF supported eviction types
194 */
195 typedef enum {
196 ocf_eviction_lru = 0,
197 /*!< Last recently used eviction policy */
198
199 ocf_eviction_max,
200 /*!< Stopper of enumerator */
201
202 ocf_eviction_default = ocf_eviction_lru,
203 /*!< Default eviction policy */
204 } ocf_eviction_t;
205
206 /**
207 * OCF supported Write-Back cleaning policies type
208 */
209 typedef enum {
210 ocf_cleaning_nop = 0,
211 /*!< Cleaning won't happen in background. Only on eviction or
212 * during cache stop
213 */
214
215 ocf_cleaning_alru,
216 /*!< Approximately recently used. Cleaning thread in the
217 * background enabled which cleans dirty data during IO
218 * inactivity.
219 */
220
221 ocf_cleaning_acp,
222 /*!< Cleaning algorithm attempts to reduce core device seek
223 * distance. Cleaning thread runs concurrently with I/O.
224 */
225
226 ocf_cleaning_max,
227 /*!< Stopper of enumerator */
228
229 ocf_cleaning_default = ocf_cleaning_alru,
230 /*!< Default cleaning policy type */
231 } ocf_cleaning_t;
232
233 /**
234 * OCF supported cache line sizes in bytes
235 */
236 typedef enum {
237 ocf_cache_line_size_4 = 4 * KiB,
238 /*!< 4 kiB */
239
240 ocf_cache_line_size_8 = 8 * KiB,
241 /*!< 8 kiB */
242
243 ocf_cache_line_size_16 = 16 * KiB,
244 /*!< 16 kiB */
245
246 ocf_cache_line_size_32 = 32 * KiB,
247 /*!< 32 kiB */
248
249 ocf_cache_line_size_64 = 64 * KiB,
250 /*!< 64 kiB */
251
252 ocf_cache_line_size_default = ocf_cache_line_size_4,
253 /*!< Default cache line size */
254
255 ocf_cache_line_size_min = ocf_cache_line_size_4,
256 /*!< Minimum cache line size */
257
258 ocf_cache_line_size_max = ocf_cache_line_size_64,
259 /*!< Maximal cache line size */
260
261 ocf_cache_line_size_inf = ~0ULL,
262 /*!< Force enum to be 64-bit */
263 } ocf_cache_line_size_t;
264
265 /**
266 * Metadata layout
267 */
268 typedef enum {
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;
274
275 /**
276 * @name OCF IO class definitions
277 */
278 /**
279 * Maximum numbers of IO classes per cache instance
280 */
281 #define OCF_IO_CLASS_MAX OCF_CONFIG_MAX_IO_CLASSES
282 /**
283 * Minimum value of a valid IO class ID
284 */
285 #define OCF_IO_CLASS_ID_MIN 0
286 /**
287 * Maximum value of a valid IO class ID
288 */
289 #define OCF_IO_CLASS_ID_MAX (OCF_IO_CLASS_MAX - 1)
290 /**
291 * Invalid value of IO class id
292 */
293 #define OCF_IO_CLASS_INVALID OCF_IO_CLASS_MAX
294
295 /** Maximum size of the IO class name */
296 #define OCF_IO_CLASS_NAME_MAX 1024
297
298 /** IO class priority which indicates pinning */
299 #define OCF_IO_CLASS_PRIO_PINNED -1
300
301 /** The highest IO class priority */
302 #define OCF_IO_CLASS_PRIO_HIGHEST 0
303
304 /** The lowest IO class priority */
305 #define OCF_IO_CLASS_PRIO_LOWEST 255
306
307 /** Default IO class priority */
308 #define OCF_IO_CLASS_PRIO_DEFAULT OCF_IO_CLASS_PRIO_LOWEST
309 /**
310 * @}
311 */
312
313 /**
314 * @name I/O operations
315 * @{
316 */
317 #define OCF_READ 0
318 #define OCF_WRITE 1
319 /**
320 * @}
321 */
322
323 /**
324 * @name OCF cleaner definitions
325 * @{
326 */
327 #define OCF_CLEANER_DISABLE ~0U
328 /**
329 * @}
330 */
331
332 #define MAX_TRIM_RQ_SIZE (1 * MiB)
333
334 #endif /* __OCF_DEF_H__ */