Open CAS Framework
Open source framework of Cache Acceleration Software
ocf_ctx.h
Go to the documentation of this file.
1 /*
2  * Copyright(c) 2012-2020 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause-Clear
4  */
5 
6 #ifndef __OCF_CTX_H__
7 #define __OCF_CTX_H__
8 
14 #include "ocf_volume.h"
15 #include "ocf_logger.h"
16 
20 typedef enum {
26 
30 struct ocf_data_ops {
38  ctx_data_t *(*alloc)(uint32_t pages);
39 
45  void (*free)(ctx_data_t *data);
46 
55  int (*mlock)(ctx_data_t *data);
56 
62  void (*munlock)(ctx_data_t *data);
63 
73  uint32_t (*read)(void *dst, ctx_data_t *src, uint32_t size);
74 
84  uint32_t (*write)(ctx_data_t *dst, const void *src, uint32_t size);
85 
94  uint32_t (*zero)(ctx_data_t *dst, uint32_t size);
95 
106  uint32_t (*seek)(ctx_data_t *dst, ctx_data_seek_t seek, uint32_t size);
107 
119  uint64_t (*copy)(ctx_data_t *dst, ctx_data_t *src,
120  uint64_t to, uint64_t from, uint64_t bytes);
121 
127  void (*secure_erase)(ctx_data_t *dst);
128 };
129 
145  int (*init)(ocf_cleaner_t c);
146 
152  void (*kick)(ocf_cleaner_t c);
153 
159  void (*stop)(ocf_cleaner_t c);
160 };
161 
177  int (*init)(ocf_metadata_updater_t mu);
178 
187  void (*kick)(ocf_metadata_updater_t mu);
188 
194  void (*stop)(ocf_metadata_updater_t mu);
195 };
196 
200 struct ocf_ctx_ops {
201  /* Context data operations */
202  struct ocf_data_ops data;
203 
204  /* Cleaner operations */
205  struct ocf_cleaner_ops cleaner;
206 
207  /* Metadata updater operations */
208  struct ocf_metadata_updater_ops metadata_updater;
209 
210  /* Logger operations */
211  struct ocf_logger_ops logger;
212 };
213 
215  /* Context name */
216  const char *name;
217 
218  /* Context operations */
219  const struct ocf_ctx_ops ops;
220 
221  /* Context logger priv */
222  void *logger_priv;
223 };
224 
237 int ocf_ctx_register_volume_type(ocf_ctx_t ctx, uint8_t type_id,
238  const struct ocf_volume_properties *properties);
239 
246 void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id);
247 
259 
271 
284  struct ocf_volume_uuid *uuid, uint8_t type_id);
285 
294 int ocf_ctx_create(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg);
295 
301 void ocf_ctx_get(ocf_ctx_t ctx);
302 
308 void ocf_ctx_put(ocf_ctx_t ctx);
309 
310 #endif /* __OCF_CTX_H__ */
void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id)
Unregister volume interface.
void ocf_ctx_put(ocf_ctx_t ctx)
Decrease reference counter of ctx.
void ctx_data_t
handle to object designating ocf context object
Definition: ocf_types.h:73
int ocf_ctx_get_volume_type_id(ocf_ctx_t ctx, ocf_volume_type_t type)
Get volume type id by type.
void(* munlock)(ctx_data_t *data)
Unlock context data buffer.
Definition: ocf_ctx.h:62
struct ocf_volume_type * ocf_volume_type_t
handle to volume type
Definition: ocf_types.h:63
struct ocf_ctx * ocf_ctx_t
handle to object designating ocf context
Definition: ocf_types.h:38
Context data representation ops.
Definition: ocf_ctx.h:30
uint32_t(* write)(ctx_data_t *dst, const void *src, uint32_t size)
Write raw data buffer into context data buffer.
Definition: ocf_ctx.h:84
void ocf_ctx_get(ocf_ctx_t ctx)
Increase reference counter of ctx.
Definition: ocf_ctx.h:214
int ocf_ctx_register_volume_type(ocf_ctx_t ctx, uint8_t type_id, const struct ocf_volume_properties *properties)
Register volume interface.
void(* free)(ctx_data_t *data)
Free context data buffer.
Definition: ocf_ctx.h:45
uint64_t(* copy)(ctx_data_t *dst, ctx_data_t *src, uint64_t to, uint64_t from, uint64_t bytes)
Copy context data buffer content.
Definition: ocf_ctx.h:119
uint32_t(* read)(void *dst, ctx_data_t *src, uint32_t size)
Read from environment data buffer into raw data buffer.
Definition: ocf_ctx.h:73
Logger API.
OCF volume UUID.
Definition: ocf_volume.h:28
OCF context specific operation.
Definition: ocf_ctx.h:200
Definition: ocf_logger.h:31
Metadata updater operations.
Definition: ocf_ctx.h:165
int ocf_ctx_volume_create(ocf_ctx_t ctx, ocf_volume_t *volume, struct ocf_volume_uuid *uuid, uint8_t type_id)
Create volume of given type.
OCF volume API.
Definition: ocf_ctx.h:23
uint32_t(* seek)(ctx_data_t *dst, ctx_data_seek_t seek, uint32_t size)
Seek read/write head in context data buffer for specified offset.
Definition: ocf_ctx.h:106
uint32_t(* zero)(ctx_data_t *dst, uint32_t size)
Zero context data buffer.
Definition: ocf_ctx.h:94
struct ocf_volume * ocf_volume_t
handle to object designating ocf volume
Definition: ocf_types.h:56
ocf_volume_type_t ocf_ctx_get_volume_type(ocf_ctx_t ctx, uint8_t type_id)
Get volume type operations by type id.
struct ocf_cleaner * ocf_cleaner_t
handle to cleaner
Definition: ocf_types.h:83
Definition: ocf_ctx.h:21
void(* secure_erase)(ctx_data_t *dst)
Erase content of data buffer.
Definition: ocf_ctx.h:127
int ocf_ctx_create(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg)
Create and initialize OCF context.
int(* mlock)(ctx_data_t *data)
Lock context data buffer to disable swap-out.
Definition: ocf_ctx.h:55
Cleaner operations.
Definition: ocf_ctx.h:133
struct ocf_metadata_updater * ocf_metadata_updater_t
handle to metadata_updater
Definition: ocf_types.h:88
ctx_data_seek_t
Seeking start position in environment data buffer.
Definition: ocf_ctx.h:20
This structure describes volume properties.
Definition: ocf_volume.h:126