Open CAS Framework
Open source framework of Cache Acceleration Software
ocf_io.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 
7 #ifndef __OCF_IO_H__
8 #define __OCF_IO_H__
9 
10 #include "ocf_types.h"
11 
17 struct ocf_io;
18 
26 typedef void (*ocf_start_io_t)(struct ocf_io *io);
27 
35 typedef void (*ocf_handle_io_t)(struct ocf_io *io, void *opaque);
36 
45 typedef void (*ocf_end_io_t)(struct ocf_io *io, int error);
46 
50 struct ocf_io {
54  uint64_t addr;
55 
59  uint64_t flags;
60 
64  uint32_t bytes;
65 
69  uint32_t io_class;
70 
74  uint32_t dir;
75 
80 
85 
90 
95 
99  void *priv1;
100 
104  void *priv2;
105 };
106 
110 struct ocf_io_ops {
121  int (*set_data)(struct ocf_io *io, ctx_data_t *data,
122  uint32_t offset);
123 
131  ctx_data_t *(*get_data)(struct ocf_io *io);
132 };
133 
141 void *ocf_io_get_priv(struct ocf_io *io);
142 
150 void ocf_io_get(struct ocf_io *io);
151 
159 void ocf_io_put(struct ocf_io *io);
160 
168 static inline void ocf_io_set_cmpl(struct ocf_io *io, void *context,
169  void *context2, ocf_end_io_t fn)
170 {
171  io->priv1 = context;
172  io->priv2 = context2;
173  io->end = fn;
174 }
175 
182 static inline void ocf_io_set_start(struct ocf_io *io, ocf_start_io_t fn)
183 {
184  io->start = fn;
185 }
186 
193 static inline void ocf_io_set_handle(struct ocf_io *io, ocf_handle_io_t fn)
194 {
195  io->handle = fn;
196 }
197 
210 int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data, uint32_t offset);
211 
221 ctx_data_t *ocf_io_get_data(struct ocf_io *io);
222 
229 void ocf_io_handle(struct ocf_io *io, void *opaque);
230 
237 
238 #endif /* __OCF_IO_H__ */
void(* ocf_end_io_t)(struct ocf_io *io, int error)
OCF IO completion.
Definition: ocf_io.h:45
ocf_volume_t ocf_io_get_volume(struct ocf_io *io)
Get volume associated with io.
void ctx_data_t
handle to object designating ocf context object
Definition: ocf_types.h:73
OCF IO main structure.
Definition: ocf_io.h:50
void * priv2
OCF IO private 2.
Definition: ocf_io.h:104
uint64_t flags
OCF IO flags.
Definition: ocf_io.h:59
ocf_start_io_t start
OCF IO start function.
Definition: ocf_io.h:84
void(* ocf_start_io_t)(struct ocf_io *io)
OCF IO start.
Definition: ocf_io.h:26
OCF IO operations set structure.
Definition: ocf_io.h:110
OCF types.
uint32_t dir
OCF IO direction.
Definition: ocf_io.h:74
void(* ocf_handle_io_t)(struct ocf_io *io, void *opaque)
OCF IO handle.
Definition: ocf_io.h:35
uint32_t io_class
OCF IO destination class.
Definition: ocf_io.h:69
struct ocf_volume * ocf_volume_t
handle to object designating ocf volume
Definition: ocf_types.h:56
struct ocf_queue * ocf_queue_t
handle to I/O queue
Definition: ocf_types.h:78
int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data, uint32_t offset)
Set up data vector in OCF IO.
uint64_t addr
OCF IO destination address.
Definition: ocf_io.h:54
void ocf_io_handle(struct ocf_io *io, void *opaque)
Handle IO in cache engine.
uint32_t bytes
OCF IO size in bytes.
Definition: ocf_io.h:64
void * ocf_io_get_priv(struct ocf_io *io)
Get IO private context structure.
void * priv1
OCF IO private 1.
Definition: ocf_io.h:99
ctx_data_t * ocf_io_get_data(struct ocf_io *io)
Get data vector from OCF IO.
ocf_handle_io_t handle
OCF IO handle function.
Definition: ocf_io.h:89
ocf_end_io_t end
OCF IO completion function.
Definition: ocf_io.h:94
void ocf_io_get(struct ocf_io *io)
Increase reference counter in OCF IO.
void ocf_io_put(struct ocf_io *io)
Decrease reference counter in OCF IO.
ocf_queue_t io_queue
Queue handle.
Definition: ocf_io.h:79