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 72474A0032;
	Mon, 18 Jul 2022 15:26:16 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id EEB5040A8B;
	Mon, 18 Jul 2022 15:26:15 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by mails.dpdk.org (Postfix) with ESMTP id 515B140041
 for <dev@dpdk.org>; Mon, 18 Jul 2022 15:26:13 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1658150773; x=1689686773;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=QGOlaI25Cq/W2w3fmxfgarFtx5//9Ylju/pTtyV5fZc=;
 b=WcJ/DMY0Rsu4b8avAUxrZ/NBsuZyicY68BAqglodtLCubuqAW/wzEy1U
 ubzGcn3GbKIbuvguhlwk8jlSi8DKsmEI32ZVNbwuvtkuzf+Ytdnd7bRtk
 KFs2iWdO/YAyu3TyUJWc9qh6vxzl4eeHMAaNOloi2/5h2HCEQYO+w5V+p
 zKg9fk6Bi2rz1fBx6IIzaVYVYod4GMIKSFb2S8nza4IVg/giF9fmjBjw4
 CIfBT+D6bOTaPd68kmALaqvRyTFaSyd9HCRP6SxER24FtCPi4hVk/fj0n
 Gcg3U/78XT/KgojwyX5dRsP8ew0jyxgx9cxtw/PMvnBUB+DVlt6AU/fNj Q==;
X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="284974521"
X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="284974521"
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 18 Jul 2022 06:26:05 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="655275247"
Received: from silpixa00400573.ir.intel.com (HELO
 silpixa00400573.ger.corp.intel.com.) ([10.237.223.157])
 by fmsmga008.fm.intel.com with ESMTP; 18 Jul 2022 06:26:04 -0700
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: "Kamalakannan R ." <kamalakannan.r@intel.com>
Subject: [PATCH V2 1/9] pipeline: move specification data structures to
 internal header
Date: Mon, 18 Jul 2022 13:25:55 +0000
Message-Id: <20220718132603.339314-1-cristian.dumitrescu@intel.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20220718130713.339003-1-cristian.dumitrescu@intel.com>
References: <20220718130713.339003-1-cristian.dumitrescu@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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 all the pipeline object specification data structures to an
internal header file.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Kamalakannan R. <kamalakannan.r@intel.com>
---
 lib/pipeline/rte_swx_pipeline_spec.c | 126 +------------------
 lib/pipeline/rte_swx_pipeline_spec.h | 176 +++++++++++++++++++++++++++
 2 files changed, 177 insertions(+), 125 deletions(-)
 create mode 100644 lib/pipeline/rte_swx_pipeline_spec.h

diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c
index 904b9eb471..5e07b4f794 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.c
+++ b/lib/pipeline/rte_swx_pipeline_spec.c
@@ -9,7 +9,7 @@
 
 #include <rte_common.h>
 
-#include "rte_swx_pipeline.h"
+#include "rte_swx_pipeline_spec.h"
 
 #ifndef MAX_LINE_LENGTH
 #define MAX_LINE_LENGTH 2048
@@ -34,15 +34,7 @@
 
 /*
  * extobj.
- *
- * extobj OBJ_NAME instanceof OBJ_TYPE [ pragma OBJ_CREATE_ARGS ]
  */
-struct extobj_spec {
-	char *name;
-	char *extern_type_name;
-	char *pragma;
-};
-
 static void
 extobj_spec_free(struct extobj_spec *s)
 {
@@ -104,18 +96,7 @@ extobj_statement_parse(struct extobj_spec *s,
 /*
  * struct.
  *
- * struct STRUCT_TYPE_NAME {
- *	bit<SIZE> | varbit<SIZE> FIELD_NAME
- *	...
- * }
  */
-struct struct_spec {
-	char *name;
-	struct rte_swx_field_params *fields;
-	uint32_t n_fields;
-	int varbit;
-};
-
 static void
 struct_spec_free(struct struct_spec *s)
 {
@@ -293,13 +274,7 @@ struct_block_parse(struct struct_spec *s,
 /*
  * header.
  *
- * header HEADER_NAME instanceof STRUCT_TYPE_NAME
  */
-struct header_spec {
-	char *name;
-	char *struct_type_name;
-};
-
 static void
 header_spec_free(struct header_spec *s)
 {
@@ -351,12 +326,7 @@ header_statement_parse(struct header_spec *s,
 /*
  * metadata.
  *
- * metadata instanceof STRUCT_TYPE_NAME
  */
-struct metadata_spec {
-	char *struct_type_name;
-};
-
 static void
 metadata_spec_free(struct metadata_spec *s)
 {
@@ -400,18 +370,7 @@ metadata_statement_parse(struct metadata_spec *s,
 /*
  * action.
  *
- * action ACTION_NAME args none | instanceof STRUCT_TYPE_NAME {
- *	INSTRUCTION
- *	...
- * }
  */
-struct action_spec {
-	char *name;
-	char *args_struct_type_name;
-	const char **instructions;
-	uint32_t n_instructions;
-};
-
 static void
 action_spec_free(struct action_spec *s)
 {
@@ -540,29 +499,7 @@ action_block_parse(struct action_spec *s,
 /*
  * table.
  *
- * table TABLE_NAME {
- *	key {
- *		MATCH_FIELD_NAME exact | wildcard | lpm
- *		...
- *	}
- *	actions {
- *		ACTION_NAME [ @tableonly | @defaultonly ]
- *		...
- *	}
- *	default_action ACTION_NAME args none | ARG0_NAME ARG0_VALUE ... [ const ]
- *	instanceof TABLE_TYPE_NAME
- *	pragma ARGS
- *	size SIZE
- * }
  */
-struct table_spec {
-	char *name;
-	struct rte_swx_pipeline_table_params params;
-	char *recommended_table_type_name;
-	char *args;
-	uint32_t size;
-};
-
 static void
 table_spec_free(struct table_spec *s)
 {
@@ -1084,22 +1021,7 @@ table_block_parse(struct table_spec *s,
 /*
  * selector.
  *
- * selector SELECTOR_NAME {
- *	group_id FIELD_NAME
- *	selector {
- *		FIELD_NAME
- *		...
- *	}
- *	member_id FIELD_NAME
- *	n_groups N_GROUPS
- *	n_members_per_group N_MEMBERS_PER_GROUP
- * }
  */
-struct selector_spec {
-	char *name;
-	struct rte_swx_pipeline_selector_params params;
-};
-
 static void
 selector_spec_free(struct selector_spec *s)
 {
@@ -1385,31 +1307,7 @@ selector_block_parse(struct selector_spec *s,
 /*
  * learner.
  *
- * learner LEARNER_NAME {
- *	key {
- *		MATCH_FIELD_NAME
- *		...
- *	}
- *	actions {
- *		ACTION_NAME [ @tableonly | @defaultonly]
- *		...
- *	}
- *	default_action ACTION_NAME args none | ARG0_NAME ARG0_VALUE ... [ const ]
- *	size SIZE
- *	timeout {
- *		TIMEOUT_IN_SECONDS
- *		...
- *	}
- * }
  */
-struct learner_spec {
-	char *name;
-	struct rte_swx_pipeline_learner_params params;
-	uint32_t size;
-	uint32_t *timeout;
-	uint32_t n_timeouts;
-};
-
 static void
 learner_spec_free(struct learner_spec *s)
 {
@@ -1958,14 +1856,7 @@ learner_block_parse(struct learner_spec *s,
 /*
  * regarray.
  *
- * regarray NAME size SIZE initval INITVAL
  */
-struct regarray_spec {
-	char *name;
-	uint64_t init_val;
-	uint32_t size;
-};
-
 static void
 regarray_spec_free(struct regarray_spec *s)
 {
@@ -2033,13 +1924,7 @@ regarray_statement_parse(struct regarray_spec *s,
 /*
  * metarray.
  *
- * metarray NAME size SIZE
  */
-struct metarray_spec {
-	char *name;
-	uint32_t size;
-};
-
 static void
 metarray_spec_free(struct metarray_spec *s)
 {
@@ -2095,16 +1980,7 @@ metarray_statement_parse(struct metarray_spec *s,
 /*
  * apply.
  *
- * apply {
- *	INSTRUCTION
- *	...
- * }
  */
-struct apply_spec {
-	const char **instructions;
-	uint32_t n_instructions;
-};
-
 static void
 apply_spec_free(struct apply_spec *s)
 {
diff --git a/lib/pipeline/rte_swx_pipeline_spec.h b/lib/pipeline/rte_swx_pipeline_spec.h
new file mode 100644
index 0000000000..8458de878a
--- /dev/null
+++ b/lib/pipeline/rte_swx_pipeline_spec.h
@@ -0,0 +1,176 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+#include <stdint.h>
+#include <stdio.h>
+
+#include <rte_common.h>
+
+#include <rte_swx_pipeline.h>
+
+/*
+ * extobj.
+ *
+ * extobj OBJ_NAME instanceof OBJ_TYPE [ pragma OBJ_CREATE_ARGS ]
+ */
+struct extobj_spec {
+	char *name;
+	char *extern_type_name;
+	char *pragma;
+};
+
+/*
+ * struct.
+ *
+ * struct STRUCT_TYPE_NAME {
+ *	bit<SIZE> | varbit<SIZE> FIELD_NAME
+ *	...
+ * }
+ */
+struct struct_spec {
+	char *name;
+	struct rte_swx_field_params *fields;
+	uint32_t n_fields;
+	int varbit;
+};
+
+/*
+ * header.
+ *
+ * header HEADER_NAME instanceof STRUCT_TYPE_NAME
+ */
+struct header_spec {
+	char *name;
+	char *struct_type_name;
+};
+
+/*
+ * metadata.
+ *
+ * metadata instanceof STRUCT_TYPE_NAME
+ */
+struct metadata_spec {
+	char *struct_type_name;
+};
+
+/*
+ * action.
+ *
+ * action ACTION_NAME args none | instanceof STRUCT_TYPE_NAME {
+ *	INSTRUCTION
+ *	...
+ * }
+ */
+struct action_spec {
+	char *name;
+	char *args_struct_type_name;
+	const char **instructions;
+	uint32_t n_instructions;
+};
+
+/*
+ * table.
+ *
+ * table TABLE_NAME {
+ *	key {
+ *		MATCH_FIELD_NAME exact | wildcard | lpm
+ *		...
+ *	}
+ *	actions {
+ *		ACTION_NAME [ @tableonly | @defaultonly ]
+ *		...
+ *	}
+ *	default_action ACTION_NAME args none | ARG0_NAME ARG0_VALUE ... [ const ]
+ *	instanceof TABLE_TYPE_NAME
+ *	pragma ARGS
+ *	size SIZE
+ * }
+ */
+struct table_spec {
+	char *name;
+	struct rte_swx_pipeline_table_params params;
+	char *recommended_table_type_name;
+	char *args;
+	uint32_t size;
+};
+
+/*
+ * selector.
+ *
+ * selector SELECTOR_NAME {
+ *	group_id FIELD_NAME
+ *	selector {
+ *		FIELD_NAME
+ *		...
+ *	}
+ *	member_id FIELD_NAME
+ *	n_groups N_GROUPS
+ *	n_members_per_group N_MEMBERS_PER_GROUP
+ * }
+ */
+struct selector_spec {
+	char *name;
+	struct rte_swx_pipeline_selector_params params;
+};
+
+/*
+ * learner.
+ *
+ * learner LEARNER_NAME {
+ *	key {
+ *		MATCH_FIELD_NAME
+ *		...
+ *	}
+ *	actions {
+ *		ACTION_NAME [ @tableonly | @defaultonly]
+ *		...
+ *	}
+ *	default_action ACTION_NAME args none | ARG0_NAME ARG0_VALUE ... [ const ]
+ *	size SIZE
+ *	timeout {
+ *		TIMEOUT_IN_SECONDS
+ *		...
+ *	}
+ * }
+ */
+struct learner_spec {
+	char *name;
+	struct rte_swx_pipeline_learner_params params;
+	uint32_t size;
+	uint32_t *timeout;
+	uint32_t n_timeouts;
+};
+
+/*
+ * regarray.
+ *
+ * regarray NAME size SIZE initval INITVAL
+ */
+struct regarray_spec {
+	char *name;
+	uint64_t init_val;
+	uint32_t size;
+};
+
+/*
+ * metarray.
+ *
+ * metarray NAME size SIZE
+ */
+struct metarray_spec {
+	char *name;
+	uint32_t size;
+};
+
+/*
+ * apply.
+ *
+ * apply {
+ *	INSTRUCTION
+ *	...
+ * }
+ */
+struct apply_spec {
+	const char **instructions;
+	uint32_t n_instructions;
+};
-- 
2.34.1