2 * Copyright(c) 2019 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef __UTILS_PIPELINE_H__
7 #define __UTILS_PIPELINE_H__
9 #include "../ocf_cache_priv.h"
11 enum ocf_pipeline_step_type
{
12 ocf_pipeline_step_single
,
13 ocf_pipeline_step_foreach
,
14 ocf_pipeline_step_terminator
,
17 enum ocf_pipeline_arg_type
{
18 ocf_pipeline_arg_none
,
21 ocf_pipeline_arg_terminator
,
24 struct ocf_pipeline_arg
{
25 enum ocf_pipeline_arg_type type
;
32 typedef struct ocf_pipeline_arg
*ocf_pipeline_arg_t
;
34 #define OCF_PL_ARG_NONE() \
35 { .type = ocf_pipeline_arg_none, }
37 #define OCF_PL_ARG_INT(_int) \
38 { .type = ocf_pipeline_arg_int, .val.i = _int }
40 #define OCF_PL_ARG_PTR(_ptr) \
41 { .type = ocf_pipeline_arg_ptr, .val.p = _ptr }
43 #define OCF_PL_ARG_TERMINATOR() \
44 { .type = ocf_pipeline_arg_terminator, }
46 static inline int ocf_pipeline_arg_get_int(ocf_pipeline_arg_t arg
)
48 ENV_BUG_ON(arg
->type
!= ocf_pipeline_arg_int
);
53 static inline void *ocf_pipeline_arg_get_ptr(ocf_pipeline_arg_t arg
)
55 ENV_BUG_ON(arg
->type
!= ocf_pipeline_arg_ptr
);
60 typedef struct ocf_pipeline
*ocf_pipeline_t
;
62 typedef void (*ocf_pipeline_step_hndl_t
)(ocf_pipeline_t pipeline
,
63 void *priv
, ocf_pipeline_arg_t arg
);
65 typedef void (*ocf_pipeline_finish_t
)(ocf_pipeline_t pipeline
,
66 void *priv
, int error
);
68 struct ocf_pipeline_step
{
69 enum ocf_pipeline_step_type type
;
70 ocf_pipeline_step_hndl_t hndl
;
72 struct ocf_pipeline_arg arg
;
73 struct ocf_pipeline_arg
*args
;
77 #define OCF_PL_STEP(_hndl) \
79 .type = ocf_pipeline_step_single, \
83 #define OCF_PL_STEP_ARG_INT(_hndl, _int) \
85 .type = ocf_pipeline_step_single, \
88 .type = ocf_pipeline_arg_int, \
93 #define OCF_PL_STEP_ARG_PTR(_hndl, _ptr) \
95 .type = ocf_pipeline_step_single, \
98 .type = ocf_pipeline_arg_ptr, \
103 #define OCF_PL_STEP_FOREACH(_hndl, _args) \
105 .type = ocf_pipeline_step_foreach, \
110 #define OCF_PL_STEP_TERMINATOR() \
112 .type = ocf_pipeline_step_terminator, \
115 struct ocf_pipeline_properties
{
117 ocf_pipeline_finish_t finish
;
118 struct ocf_pipeline_step steps
[];
121 int ocf_pipeline_create(ocf_pipeline_t
*pipeline
, ocf_cache_t cache
,
122 struct ocf_pipeline_properties
*properties
);
124 void ocf_pipeline_set_priv(ocf_pipeline_t pipeline
, void *priv
);
126 void *ocf_pipeline_get_priv(ocf_pipeline_t pipeline
);
128 void ocf_pipeline_destroy(ocf_pipeline_t pipeline
);
130 void ocf_pipeline_next(ocf_pipeline_t pipeline
);
132 void ocf_pipeline_finish(ocf_pipeline_t pipeline
, int error
);
134 #endif /* __UTILS_PIPELINE_H__ */