Pipeline conditional step
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com> Signed-off-by: Piotr Debski <piotr.debski@intel.com>
This commit is contained in:
parent
ae735b4434
commit
1a27b07f72
@ -1118,7 +1118,6 @@ out:
|
||||
|
||||
struct ocf_pipeline_arg ocf_metadata_load_all_args[] = {
|
||||
OCF_PL_ARG_INT(metadata_segment_core_runtime),
|
||||
OCF_PL_ARG_INT(metadata_segment_cleaning),
|
||||
OCF_PL_ARG_INT(metadata_segment_lru),
|
||||
OCF_PL_ARG_INT(metadata_segment_collision),
|
||||
OCF_PL_ARG_INT(metadata_segment_list_info),
|
||||
@ -1126,14 +1125,26 @@ struct ocf_pipeline_arg ocf_metadata_load_all_args[] = {
|
||||
OCF_PL_ARG_TERMINATOR(),
|
||||
};
|
||||
|
||||
static bool ocf_metadata_check_disabled_segment(ocf_pipeline_t pipeline,
|
||||
ocf_pipeline_arg_t arg)
|
||||
{
|
||||
....
|
||||
}
|
||||
|
||||
struct ocf_pipeline_properties ocf_metadata_load_all_pipeline_props = {
|
||||
.priv_size = sizeof(struct ocf_metadata_context),
|
||||
.finish = ocf_metadata_load_all_finish,
|
||||
.steps = {
|
||||
OCF_PL_STEP_CONDITIONAL(ocf_metadata_load_segment,
|
||||
metadata_segment_cleaning,
|
||||
ocf_metadata_check_disabled_segment),
|
||||
OCF_PL_STEP_FOREACH(ocf_metadata_load_segment,
|
||||
ocf_metadata_load_all_args),
|
||||
ocf_metadata_load_all_args,
|
||||
|
||||
// conditional sfor cleaning
|
||||
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc,
|
||||
ocf_metadata_load_all_args),
|
||||
ocf_metadata_load_all_args,
|
||||
checker),
|
||||
OCF_PL_STEP_TERMINATOR(),
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2021 Intel Corporation
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -39,6 +39,13 @@ static int _ocf_pipeline_run_step(struct ocf_request *req)
|
||||
pipeline->next_step++;
|
||||
step->hndl(pipeline, pipeline->priv, &step->arg);
|
||||
return 0;
|
||||
case ocf_pipeline_step_conditional:
|
||||
pipeline->next_step++;
|
||||
if (step->pred(pipeline, pipeline->priv, &step->arg)) {
|
||||
step->hndl(pipeline, pipeline->priv, &step->arg);
|
||||
return 0;
|
||||
}
|
||||
continue;
|
||||
case ocf_pipeline_step_foreach:
|
||||
arg = &step->args[pipeline->next_arg++];
|
||||
if (arg->type == ocf_pipeline_arg_terminator) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright(c) 2019-2021 Intel Corporation
|
||||
* Copyright(c) 2019-2022 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
enum ocf_pipeline_step_type {
|
||||
ocf_pipeline_step_single,
|
||||
ocf_pipeline_step_foreach,
|
||||
ocf_pipeline_step_conditional,
|
||||
ocf_pipeline_step_terminator,
|
||||
};
|
||||
|
||||
@ -65,9 +66,13 @@ typedef void (*ocf_pipeline_step_hndl_t)(ocf_pipeline_t pipeline,
|
||||
typedef void (*ocf_pipeline_finish_t)(ocf_pipeline_t pipeline,
|
||||
void *priv, int error);
|
||||
|
||||
typedef bool (*ocf_pipeline_cond_step_predicate_t)(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg);
|
||||
|
||||
struct ocf_pipeline_step {
|
||||
enum ocf_pipeline_step_type type;
|
||||
ocf_pipeline_step_hndl_t hndl;
|
||||
ocf_pipeline_cond_step_predicate_t pred;
|
||||
union {
|
||||
struct ocf_pipeline_arg arg;
|
||||
struct ocf_pipeline_arg *args;
|
||||
@ -112,6 +117,35 @@ struct ocf_pipeline_step {
|
||||
.type = ocf_pipeline_step_terminator, \
|
||||
}
|
||||
|
||||
#define OCF_PL_STEP_COND(_pred, _hndl) \
|
||||
{ \
|
||||
.pred = _pred, \
|
||||
.type = ocf_pipeline_step_conditional, \
|
||||
.hndl = _hndl, \
|
||||
}
|
||||
|
||||
#define OCF_PL_STEP_COND_ARG_INT(_pred, _hndl, _int) \
|
||||
{ \
|
||||
.pred = _pred, \
|
||||
.type = ocf_pipeline_step_conditional, \
|
||||
.hndl = _hndl, \
|
||||
.arg = { \
|
||||
.type = ocf_pipeline_arg_int, \
|
||||
.val.i = _int, \
|
||||
} \
|
||||
}
|
||||
|
||||
#define OCF_PL_STEP_COND_ARG_PTR(_pred, _hndl, _ptr) \
|
||||
{ \
|
||||
.pred = _pred, \
|
||||
.type = ocf_pipeline_step_conditional, \
|
||||
.hndl = _hndl, \
|
||||
.arg = { \
|
||||
.type = ocf_pipeline_arg_ptr, \
|
||||
.val.p = _ptr, \
|
||||
} \
|
||||
}
|
||||
|
||||
struct ocf_pipeline_properties {
|
||||
uint32_t priv_size;
|
||||
ocf_pipeline_finish_t finish;
|
||||
|
Loading…
Reference in New Issue
Block a user