Add specification data structure for the entire pipeline.

Signed-off-by: Cristian Dumitrescu <cristian.dumitre...@intel.com>
Signed-off-by: Kamalakannan R. <kamalakanna...@intel.com>
---
 lib/pipeline/rte_swx_pipeline_spec.c | 21 ++++++++++++++++++
 lib/pipeline/rte_swx_pipeline_spec.h | 32 ++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/lib/pipeline/rte_swx_pipeline_spec.c 
b/lib/pipeline/rte_swx_pipeline_spec.c
index 5e07b4f794..642091b678 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.c
+++ b/lib/pipeline/rte_swx_pipeline_spec.c
@@ -2082,6 +2082,27 @@ apply_block_parse(struct apply_spec *s,
 /*
  * Pipeline.
  */
+void
+pipeline_spec_free(struct pipeline_spec *s)
+{
+       if (!s)
+               return;
+
+       free(s->extobjs);
+       free(s->structs);
+       free(s->headers);
+       free(s->metadata);
+       free(s->actions);
+       free(s->tables);
+       free(s->selectors);
+       free(s->learners);
+       free(s->regarrays);
+       free(s->metarrays);
+       free(s->apply);
+
+       memset(s, 0, sizeof(struct pipeline_spec));
+}
+
 int
 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p,
                                 FILE *spec,
diff --git a/lib/pipeline/rte_swx_pipeline_spec.h 
b/lib/pipeline/rte_swx_pipeline_spec.h
index 8458de878a..e1170a33b1 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.h
+++ b/lib/pipeline/rte_swx_pipeline_spec.h
@@ -174,3 +174,35 @@ struct apply_spec {
        const char **instructions;
        uint32_t n_instructions;
 };
+
+/*
+ * Pipeline.
+ */
+struct pipeline_spec {
+       struct extobj_spec *extobjs;
+       struct struct_spec *structs;
+       struct header_spec *headers;
+       struct metadata_spec *metadata;
+       struct action_spec *actions;
+       struct table_spec *tables;
+       struct selector_spec *selectors;
+       struct learner_spec *learners;
+       struct regarray_spec *regarrays;
+       struct metarray_spec *metarrays;
+       struct apply_spec *apply;
+
+       uint32_t n_extobjs;
+       uint32_t n_structs;
+       uint32_t n_headers;
+       uint32_t n_metadata;
+       uint32_t n_actions;
+       uint32_t n_tables;
+       uint32_t n_selectors;
+       uint32_t n_learners;
+       uint32_t n_regarrays;
+       uint32_t n_metarrays;
+       uint32_t n_apply;
+};
+
+void
+pipeline_spec_free(struct pipeline_spec *s);
-- 
2.34.1

Reply via email to