From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 533EBA0C43;
	Sat, 27 Nov 2021 00:51:45 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 4A8764274C;
	Sat, 27 Nov 2021 00:51:37 +0100 (CET)
Received: from mga07.intel.com (mga07.intel.com [134.134.136.100])
 by mails.dpdk.org (Postfix) with ESMTP id AC01041223
 for <dev@dpdk.org>; Sat, 27 Nov 2021 00:51:34 +0100 (CET)
X-IronPort-AV: E=McAfee;i="6200,9189,10180"; a="299130310"
X-IronPort-AV: E=Sophos;i="5.87,267,1631602800"; d="scan'208";a="299130310"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 26 Nov 2021 15:51:33 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.87,267,1631602800"; d="scan'208";a="510837562"
Received: from silpixa00400573.ir.intel.com (HELO
 silpixa00400573.ger.corp.intel.com) ([10.237.223.107])
 by orsmga008.jf.intel.com with ESMTP; 26 Nov 2021 15:51:32 -0800
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: yogesh.jangra@intel.com
Subject: [PATCH 3/4] pipeline: move table type registration to library
Date: Fri, 26 Nov 2021 23:51:28 +0000
Message-Id: <20211126235129.35781-3-cristian.dumitrescu@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20211126235129.35781-1-cristian.dumitrescu@intel.com>
References: <20211126235129.35781-1-cristian.dumitrescu@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@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..a05a4edc7d 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