Move the table type registration for the well known table types from
the application to the pipeline library.

Signed-off-by: Cristian Dumitrescu <cristian.dumitre...@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jan...@intel.com>
---
 examples/pipeline/obj.c         | 16 ----------------
 lib/pipeline/rte_swx_pipeline.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 4b2db66c46..b79f044ac7 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -16,8 +16,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
-#include <rte_swx_table_em.h>
-#include <rte_swx_table_wm.h>
 #include <rte_swx_pipeline.h>
 #include <rte_swx_ctl.h>
 
@@ -539,20 +537,6 @@ pipeline_create(struct obj *obj, const char *name, int 
numa_node)
        if (status)
                goto error;
 
-       status = rte_swx_pipeline_table_type_register(p,
-               "exact",
-               RTE_SWX_TABLE_MATCH_EXACT,
-               &rte_swx_table_exact_match_ops);
-       if (status)
-               goto error;
-
-       status = rte_swx_pipeline_table_type_register(p,
-               "wildcard",
-               RTE_SWX_TABLE_MATCH_WILDCARD,
-               &rte_swx_table_wildcard_match_ops);
-       if (status)
-               goto error;
-
        /* Node allocation */
        pipeline = calloc(1, sizeof(struct pipeline));
        if (pipeline == NULL)
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index bebad98e99..dd914fd935 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -12,6 +12,9 @@
 #include <rte_swx_port_ring.h>
 #include "rte_swx_port_source_sink.h"
 
+#include <rte_swx_table_em.h>
+#include <rte_swx_table_wm.h>
+
 #include "rte_swx_pipeline_internal.h"
 
 #define CHECK(condition, err_code)                                             
\
@@ -9088,6 +9091,28 @@ port_out_types_register(struct rte_swx_pipeline *p)
        return 0;
 }
 
+static int
+table_types_register(struct rte_swx_pipeline *p)
+{
+       int status;
+
+       status = rte_swx_pipeline_table_type_register(p,
+               "exact",
+               RTE_SWX_TABLE_MATCH_EXACT,
+               &rte_swx_table_exact_match_ops);
+       if (status)
+               return status;
+
+       status = rte_swx_pipeline_table_type_register(p,
+               "wildcard",
+               RTE_SWX_TABLE_MATCH_WILDCARD,
+               &rte_swx_table_wildcard_match_ops);
+       if (status)
+               return status;
+
+       return 0;
+}
+
 int
 rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 {
@@ -9134,6 +9159,10 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int 
numa_node)
        if (status)
                goto error;
 
+       status = table_types_register(pipeline);
+       if (status)
+               goto error;
+
        *p = pipeline;
        return 0;
 
-- 
2.17.1

Reply via email to