1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
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__ */
|