From patchwork Mon Jul 18 13:07:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114017 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D310A0032; Mon, 18 Jul 2022 15:07:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F9D940A8B; Mon, 18 Jul 2022 15:07:18 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id EDDE140041 for ; Mon, 18 Jul 2022 15:07:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149637; x=1689685637; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QGOlaI25Cq/W2w3fmxfgarFtx5//9Ylju/pTtyV5fZc=; b=HMjaMveSiT1nrvgzhOM4N6/m3FGhkw4e/OaO81TGDdxTfjnYbVV7S6NF KNSvnujaB08Sgxslm+hnxFft8NxSn+WdxzD9YOeH3kGNctlluD7Uwj9OC mke4oEkXw4uAL19hvv3XJ7v9wTZM+AOJ8igDrgamHM0AJODxY8gBr+1Nc iu4UwHIdYu5LrX8VJWZESQ2bME7VfySKDNMZUGJDSAI/wV8HjFpxNn36z kGkGcA/5MJEYHloRNfDzgsk/5bghetp8A5iK//3ibXVwKbq33Crblh3zA QoWUHGrxThaa8Vt041l0GOJBcbLgQf3ccYPod1Sjvz0UET0kHaZd9B8Fg w==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996391" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996391" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459724" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:14 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 1/9] pipeline: move specification data structures to internal header Date: Mon, 18 Jul 2022 13:07:05 +0000 Message-Id: <20220718130713.339003-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Signed-off-by: Kamalakannan R. --- 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 -#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 | varbit 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 +#include + +#include + +#include + +/* + * 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 | varbit 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; +}; From patchwork Mon Jul 18 13:07:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114018 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D6B39A0032; Mon, 18 Jul 2022 15:07:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF4BD410E6; Mon, 18 Jul 2022 15:07:20 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id B59B040041 for ; Mon, 18 Jul 2022 15:07:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149637; x=1689685637; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UzzpIhJ2abbRozU27BFdEHiHwKlZzXx+954EfyzY78c=; b=CuyKmfKjB2jgmqNzLJw1L9Fh309fBgnCg9ax9ihKUDyLkqg5Djr7Ambv TWLemuDGSR/PkLrQx/vGAHFO5zAWriq9UWPO/aU4tfCnb88cK4+NPOpta V9N+pOL51yg8U17HYaGC6Aelgp7Ch8/GDwb6o5mW6lLfdpdksspzJ6G+u MdwenBnpfcbPYFl/MrpXfBnirgpIl3ye5QnppFSD0tIjCWDxT8uFykm6y 7jb3k9OminMcoEWUTeJwZPFErZOzIpP48Y7N1T79K94Vfrf1WbX8Xzj+/ B84Sc0EhB8qV/dljA2l6PHpyg1a7/U3GBRie3H1bv4Njzl2qBCsTE1eUj Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996399" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996399" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459728" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:15 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 2/9] pipeline: add pipeline specification data structure Date: Mon, 18 Jul 2022 13:07:06 +0000 Message-Id: <20220718130713.339003-2-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add specification data structure for the entire pipeline. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- 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); From patchwork Mon Jul 18 13:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114019 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96A80A0032; Mon, 18 Jul 2022 15:07:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5E35415D7; Mon, 18 Jul 2022 15:07:21 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 5E86940041 for ; Mon, 18 Jul 2022 15:07:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149638; x=1689685638; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nA3mlTsFN4sgH66Ylc8sT1ANSTgwb+I1wjadGSYi/H0=; b=TJpSazX1wVFYnqQdONzSWrl7WhRc041ORlbQtyAbo4gE/niSH3eXR7Wp LoSk8HDUkynFx3GzvWeeRrHgcUQi4V9EfG7EoP2jubg27oDeSBSAAZUq/ v5sN1ucEjorvWFF0bVd6431ybpFmyiUTHdXurgZSdTy9gKffOVETH4Txz U7B0epO2t0dRcf5zOXOtieVyhV82k5SV5XdxU+N+gEzfaQBcpk4+s7q1h ndL3M5HrlP25vzN4goUGkKY9FTLq0qJjyKQz2ddibLPl5c5D6el4c3/EE j38bosqKhG/KzKRlagg7vWU5K7EYERQiSro2dOFzvY2v0ASfpKjktCNLM Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996407" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996407" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459732" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:16 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 3/9] pipeline: rework the specification file-based pipeline build Date: Mon, 18 Jul 2022 13:07:07 +0000 Message-Id: <20220718130713.339003-3-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Rework the specification file-based pipeline build operation to first parse the specification file into the previously introduced pipeline specification data structure, then use this structure to configure and build the pipeline. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- lib/pipeline/rte_swx_pipeline_spec.c | 478 +++++++++++++++++++++------ lib/pipeline/rte_swx_pipeline_spec.h | 9 + 2 files changed, 385 insertions(+), 102 deletions(-) diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index 642091b678..cbbcef852b 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.c +++ b/lib/pipeline/rte_swx_pipeline_spec.c @@ -2103,11 +2103,10 @@ pipeline_spec_free(struct pipeline_spec *s) memset(s, 0, sizeof(struct pipeline_spec)); } -int -rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, - FILE *spec, - uint32_t *err_line, - const char **err_msg) +struct pipeline_spec * +pipeline_spec_parse(FILE *spec, + uint32_t *err_line, + const char **err_msg) { struct extobj_spec extobj_spec = {0}; struct struct_spec struct_spec = {0}; @@ -2120,26 +2119,29 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, struct regarray_spec regarray_spec = {0}; struct metarray_spec metarray_spec = {0}; struct apply_spec apply_spec = {0}; - uint32_t n_lines; + struct pipeline_spec *s = NULL; + uint32_t n_lines = 0; uint32_t block_mask = 0; - int status; + int status = 0; /* Check the input arguments. */ - if (!p) { + if (!spec) { if (err_line) - *err_line = 0; + *err_line = n_lines; if (err_msg) - *err_msg = "Null pipeline argument."; + *err_msg = "Invalid input argument."; status = -EINVAL; goto error; } - if (!spec) { + /* Memory allocation. */ + s = calloc(sizeof(struct pipeline_spec), 1); + if (!s) { if (err_line) - *err_line = 0; + *err_line = n_lines; if (err_msg) - *err_msg = "Null specification file argument."; - status = -EINVAL; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } @@ -2200,6 +2202,8 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, /* struct block. */ if (block_mask & (1 << STRUCT_BLOCK)) { + struct struct_spec *new_structs; + status = struct_block_parse(&struct_spec, &block_mask, tokens, @@ -2214,26 +2218,29 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_struct_type_register(p, - struct_spec.name, - struct_spec.fields, - struct_spec.n_fields, - struct_spec.varbit); - if (status) { + new_structs = realloc(s->structs, + (s->n_structs + 1) * sizeof(struct struct_spec)); + if (!new_structs) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Struct registration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - struct_spec_free(&struct_spec); + s->structs = new_structs; + memcpy(&s->structs[s->n_structs], &struct_spec, sizeof(struct struct_spec)); + s->n_structs++; + memset(&struct_spec, 0, sizeof(struct struct_spec)); continue; } /* action block. */ if (block_mask & (1 << ACTION_BLOCK)) { + struct action_spec *new_actions; + status = action_block_parse(&action_spec, &block_mask, tokens, @@ -2248,26 +2255,29 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_action_config(p, - action_spec.name, - action_spec.args_struct_type_name, - action_spec.instructions, - action_spec.n_instructions); - if (status) { + new_actions = realloc(s->actions, + (s->n_actions + 1) * sizeof(struct action_spec)); + if (!new_actions) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Action config error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - action_spec_free(&action_spec); + s->actions = new_actions; + memcpy(&s->actions[s->n_actions], &action_spec, sizeof(struct action_spec)); + s->n_actions++; + memset(&action_spec, 0, sizeof(struct action_spec)); continue; } /* table block. */ if (block_mask & (1 << TABLE_BLOCK)) { + struct table_spec *new_tables; + status = table_block_parse(&table_spec, &block_mask, tokens, @@ -2282,27 +2292,29 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_table_config(p, - table_spec.name, - &table_spec.params, - table_spec.recommended_table_type_name, - table_spec.args, - table_spec.size); - if (status) { + new_tables = realloc(s->tables, + (s->n_tables + 1) * sizeof(struct table_spec)); + if (!new_tables) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Table configuration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - table_spec_free(&table_spec); + s->tables = new_tables; + memcpy(&s->tables[s->n_tables], &table_spec, sizeof(struct table_spec)); + s->n_tables++; + memset(&table_spec, 0, sizeof(struct table_spec)); continue; } /* selector block. */ if (block_mask & (1 << SELECTOR_BLOCK)) { + struct selector_spec *new_selectors; + status = selector_block_parse(&selector_spec, &block_mask, tokens, @@ -2317,24 +2329,31 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_selector_config(p, - selector_spec.name, - &selector_spec.params); - if (status) { + new_selectors = realloc(s->selectors, + (s->n_selectors + 1) * sizeof(struct selector_spec)); + if (!new_selectors) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Selector configuration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - selector_spec_free(&selector_spec); + s->selectors = new_selectors; + memcpy(&s->selectors[s->n_selectors], + &selector_spec, + sizeof(struct selector_spec)); + s->n_selectors++; + memset(&selector_spec, 0, sizeof(struct selector_spec)); continue; } /* learner block. */ if (block_mask & (1 << LEARNER_BLOCK)) { + struct learner_spec *new_learners; + status = learner_block_parse(&learner_spec, &block_mask, tokens, @@ -2349,27 +2368,31 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_learner_config(p, - learner_spec.name, - &learner_spec.params, - learner_spec.size, - learner_spec.timeout, - learner_spec.n_timeouts); - if (status) { + new_learners = realloc(s->learners, + (s->n_learners + 1) * sizeof(struct learner_spec)); + if (!new_learners) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Learner table configuration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - learner_spec_free(&learner_spec); + s->learners = new_learners; + memcpy(&s->learners[s->n_learners], + &learner_spec, + sizeof(struct learner_spec)); + s->n_learners++; + memset(&learner_spec, 0, sizeof(struct learner_spec)); continue; } /* apply block. */ if (block_mask & (1 << APPLY_BLOCK)) { + struct apply_spec *new_apply; + status = apply_block_parse(&apply_spec, &block_mask, tokens, @@ -2384,24 +2407,28 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, continue; /* End of block. */ - status = rte_swx_pipeline_instructions_config(p, - apply_spec.instructions, - apply_spec.n_instructions); - if (status) { + new_apply = realloc(s->apply, (s->n_apply + 1) * sizeof(struct apply_spec)); + if (!new_apply) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Pipeline instructions err."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - apply_spec_free(&apply_spec); + s->apply = new_apply; + memcpy(&s->apply[s->n_apply], &apply_spec, sizeof(struct apply_spec)); + s->n_apply++; + memset(&apply_spec, 0, sizeof(struct apply_spec)); continue; } /* extobj. */ if (!strcmp(tokens[0], "extobj")) { + struct extobj_spec *new_extobjs; + status = extobj_statement_parse(&extobj_spec, tokens, n_tokens, @@ -2411,19 +2438,21 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, if (status) goto error; - status = rte_swx_pipeline_extern_object_config(p, - extobj_spec.name, - extobj_spec.extern_type_name, - extobj_spec.pragma); - if (status) { + new_extobjs = realloc(s->extobjs, + (s->n_extobjs + 1) * sizeof(struct extobj_spec)); + if (!new_extobjs) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Extern object config err."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - extobj_spec_free(&extobj_spec); + s->extobjs = new_extobjs; + memcpy(&s->extobjs[s->n_extobjs], &extobj_spec, sizeof(struct extobj_spec)); + s->n_extobjs++; + memset(&extobj_spec, 0, sizeof(struct extobj_spec)); continue; } @@ -2445,6 +2474,8 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, /* header. */ if (!strcmp(tokens[0], "header")) { + struct header_spec *new_headers; + status = header_statement_parse(&header_spec, tokens, n_tokens, @@ -2454,24 +2485,29 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, if (status) goto error; - status = rte_swx_pipeline_packet_header_register(p, - header_spec.name, - header_spec.struct_type_name); - if (status) { + new_headers = realloc(s->headers, + (s->n_headers + 1) * sizeof(struct header_spec)); + if (!new_headers) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Header registration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - header_spec_free(&header_spec); + s->headers = new_headers; + memcpy(&s->headers[s->n_headers], &header_spec, sizeof(struct header_spec)); + s->n_headers++; + memset(&header_spec, 0, sizeof(struct header_spec)); continue; } /* metadata. */ if (!strcmp(tokens[0], "metadata")) { + struct metadata_spec *new_metadata; + status = metadata_statement_parse(&metadata_spec, tokens, n_tokens, @@ -2481,17 +2517,23 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, if (status) goto error; - status = rte_swx_pipeline_packet_metadata_register(p, - metadata_spec.struct_type_name); - if (status) { + new_metadata = realloc(s->metadata, + (s->n_metadata + 1) * sizeof(struct metadata_spec)); + if (!new_metadata) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Meta-data reg err."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - metadata_spec_free(&metadata_spec); + s->metadata = new_metadata; + memcpy(&s->metadata[s->n_metadata], + &metadata_spec, + sizeof(struct metadata_spec)); + s->n_metadata++; + memset(&metadata_spec, 0, sizeof(struct metadata_spec)); continue; } @@ -2558,6 +2600,8 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, /* regarray. */ if (!strcmp(tokens[0], "regarray")) { + struct regarray_spec *new_regarrays; + status = regarray_statement_parse(®array_spec, tokens, n_tokens, @@ -2567,25 +2611,31 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, if (status) goto error; - status = rte_swx_pipeline_regarray_config(p, - regarray_spec.name, - regarray_spec.size, - regarray_spec.init_val); - if (status) { + new_regarrays = realloc(s->regarrays, + (s->n_regarrays + 1) * sizeof(struct regarray_spec)); + if (!new_regarrays) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Register array configuration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - regarray_spec_free(®array_spec); + s->regarrays = new_regarrays; + memcpy(&s->regarrays[s->n_regarrays], + ®array_spec, + sizeof(struct regarray_spec)); + s->n_regarrays++; + memset(®array_spec, 0, sizeof(struct regarray_spec)); continue; } /* metarray. */ if (!strcmp(tokens[0], "metarray")) { + struct metarray_spec *new_metarrays; + status = metarray_statement_parse(&metarray_spec, tokens, n_tokens, @@ -2595,18 +2645,23 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, if (status) goto error; - status = rte_swx_pipeline_metarray_config(p, - metarray_spec.name, - metarray_spec.size); - if (status) { + new_metarrays = realloc(s->metarrays, + (s->n_metarrays + 1) * sizeof(struct metarray_spec)); + if (!new_metarrays) { if (err_line) *err_line = n_lines; if (err_msg) - *err_msg = "Meter array configuration error."; + *err_msg = "Memory allocation failed."; + status = -ENOMEM; goto error; } - metarray_spec_free(&metarray_spec); + s->metarrays = new_metarrays; + memcpy(&s->metarrays[s->n_metarrays], + &metarray_spec, + sizeof(struct metarray_spec)); + s->n_metarrays++; + memset(&metarray_spec, 0, sizeof(struct metarray_spec)); continue; } @@ -2644,17 +2699,7 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, goto error; } - /* Pipeline build. */ - status = rte_swx_pipeline_build(p); - if (status) { - if (err_line) - *err_line = n_lines; - if (err_msg) - *err_msg = "Pipeline build error."; - goto error; - } - - return 0; + return s; error: extobj_spec_free(&extobj_spec); @@ -2668,5 +2713,234 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, regarray_spec_free(®array_spec); metarray_spec_free(&metarray_spec); apply_spec_free(&apply_spec); + pipeline_spec_free(s); + + return NULL; +} + +int +pipeline_spec_configure(struct rte_swx_pipeline *p, + struct pipeline_spec *s, + const char **err_msg) +{ + uint32_t i; + int status = 0; + + /* extobj. */ + for (i = 0; i < s->n_extobjs; i++) { + struct extobj_spec *extobj_spec = &s->extobjs[i]; + + status = rte_swx_pipeline_extern_object_config(p, + extobj_spec->name, + extobj_spec->extern_type_name, + extobj_spec->pragma); + if (status) { + if (err_msg) + *err_msg = "Extern object configuration error."; + return status; + } + } + + /* regarray. */ + for (i = 0; i < s->n_regarrays; i++) { + struct regarray_spec *regarray_spec = &s->regarrays[i]; + + status = rte_swx_pipeline_regarray_config(p, + regarray_spec->name, + regarray_spec->size, + regarray_spec->init_val); + if (status) { + if (err_msg) + *err_msg = "Register array configuration error."; + return status; + } + } + + /* metarray. */ + for (i = 0; i < s->n_metarrays; i++) { + struct metarray_spec *metarray_spec = &s->metarrays[i]; + + status = rte_swx_pipeline_metarray_config(p, + metarray_spec->name, + metarray_spec->size); + if (status) { + if (err_msg) + *err_msg = "Meter array configuration error."; + return status; + } + } + + /* struct. */ + for (i = 0; i < s->n_structs; i++) { + struct struct_spec *struct_spec = &s->structs[i]; + + status = rte_swx_pipeline_struct_type_register(p, + struct_spec->name, + struct_spec->fields, + struct_spec->n_fields, + struct_spec->varbit); + if (status) { + if (err_msg) + *err_msg = "Struct type registration error."; + return status; + } + } + + /* header. */ + for (i = 0; i < s->n_headers; i++) { + struct header_spec *header_spec = &s->headers[i]; + + status = rte_swx_pipeline_packet_header_register(p, + header_spec->name, + header_spec->struct_type_name); + if (status) { + if (err_msg) + *err_msg = "Header configuration error."; + return status; + } + } + + /* metadata. */ + for (i = 0; i < s->n_metadata; i++) { + struct metadata_spec *metadata_spec = &s->metadata[i]; + + status = rte_swx_pipeline_packet_metadata_register(p, + metadata_spec->struct_type_name); + if (status) { + if (err_msg) + *err_msg = "Meta-data registration error."; + return status; + } + } + + /* action. */ + for (i = 0; i < s->n_actions; i++) { + struct action_spec *action_spec = &s->actions[i]; + + status = rte_swx_pipeline_action_config(p, + action_spec->name, + action_spec->args_struct_type_name, + action_spec->instructions, + action_spec->n_instructions); + if (status) { + if (err_msg) + *err_msg = "Action configuration error."; + return status; + } + } + + /* table. */ + for (i = 0; i < s->n_tables; i++) { + struct table_spec *table_spec = &s->tables[i]; + + status = rte_swx_pipeline_table_config(p, + table_spec->name, + &table_spec->params, + table_spec->recommended_table_type_name, + table_spec->args, + table_spec->size); + if (status) { + if (err_msg) + *err_msg = "Table configuration error."; + return status; + } + } + + /* selector. */ + for (i = 0; i < s->n_selectors; i++) { + struct selector_spec *selector_spec = &s->selectors[i]; + + status = rte_swx_pipeline_selector_config(p, + selector_spec->name, + &selector_spec->params); + if (status) { + if (err_msg) + *err_msg = "Selector table configuration error."; + return status; + } + } + + /* learner. */ + for (i = 0; i < s->n_learners; i++) { + struct learner_spec *learner_spec = &s->learners[i]; + + status = rte_swx_pipeline_learner_config(p, + learner_spec->name, + &learner_spec->params, + learner_spec->size, + learner_spec->timeout, + learner_spec->n_timeouts); + if (status) { + if (err_msg) + *err_msg = "Learner table configuration error."; + return status; + } + } + + /* apply. */ + for (i = 0; i < s->n_apply; i++) { + struct apply_spec *apply_spec = &s->apply[i]; + + status = rte_swx_pipeline_instructions_config(p, + apply_spec->instructions, + apply_spec->n_instructions); + if (status) { + if (err_msg) + *err_msg = "Pipeline instructions configuration error."; + return status; + } + } + + return 0; +} + +int +rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, + FILE *spec_file, + uint32_t *err_line, + const char **err_msg) +{ + struct pipeline_spec *s = NULL; + int status = 0; + + /* Check the input arguments. */ + if (!p || !spec_file) { + if (err_line) + *err_line = 0; + if (err_msg) + *err_msg = "Invalid input argument."; + status = -EINVAL; + goto error; + } + + /* Spec file parse. */ + s = pipeline_spec_parse(spec_file, err_line, err_msg); + if (!s) { + status = -EINVAL; + goto error; + } + + /* Pipeline configure. */ + status = pipeline_spec_configure(p, s, err_msg); + if (status) { + if (err_line) + *err_line = 0; + goto error; + } + + /* Pipeline build. */ + status = rte_swx_pipeline_build(p); + if (status) { + if (err_line) + *err_line = 0; + if (err_msg) + *err_msg = "Pipeline build error."; + goto error; + } + + return 0; + +error: + pipeline_spec_free(s); return status; } diff --git a/lib/pipeline/rte_swx_pipeline_spec.h b/lib/pipeline/rte_swx_pipeline_spec.h index e1170a33b1..4f3a0b5958 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.h +++ b/lib/pipeline/rte_swx_pipeline_spec.h @@ -206,3 +206,12 @@ struct pipeline_spec { void pipeline_spec_free(struct pipeline_spec *s); +struct pipeline_spec * +pipeline_spec_parse(FILE *spec, + uint32_t *err_line, + const char **err_msg); + +int +pipeline_spec_configure(struct rte_swx_pipeline *p, + struct pipeline_spec *s, + const char **err_msg); From patchwork Mon Jul 18 13:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114020 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79000A0032; Mon, 18 Jul 2022 15:07:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD89E410F6; Mon, 18 Jul 2022 15:07:22 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 2D7F840041 for ; Mon, 18 Jul 2022 15:07:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149639; x=1689685639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZLYik43juPIlcjCx2NjhTSMoEmgtKsuy7FOjGirjVhk=; b=PxSlWVBsWx+GSOs1k3Lum7ByuVWubs4JFGxZHmXM3Ix7oAnpoNaVL2CZ R/d9AiD+F9A/puzVLPe/90LGea11/th0f3zXD4fPAKx+24e2k8xqlzJhM AYMuSYtIlpGz2lbG6R4tmfb3Wy53ovtTG6+4bv7E2nqISecBdjUSC3VSV CLJvaxrT5pGuMqzG5EGVNIs9STyj+y7S2FIpSnPnmCYNN1IhSmOdynvaI s1kC7X6qfCk+qUZK1zMhGfMdcfgXk5SOPxbwMfoFtckmbGjU3MtLM+z7L Bf+oR7unBVJ28WMV0ijNE4VhZIsP8gmtLbKbQHkBxrPDIoSRnTcmz5j4P w==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996414" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996414" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459736" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:17 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 4/9] pipeline: generate the code for pipeline specification structure Date: Mon, 18 Jul 2022 13:07:08 +0000 Message-Id: <20220718130713.339003-4-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add support to export the pipeline specification data structure to a C source code file. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- lib/pipeline/rte_swx_pipeline_spec.c | 621 +++++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline_spec.h | 5 + 2 files changed, 626 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index cbbcef852b..05cf952816 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.c +++ b/lib/pipeline/rte_swx_pipeline_spec.c @@ -2,6 +2,7 @@ * Copyright(c) 2020 Intel Corporation */ #include +#include #include #include #include @@ -2103,6 +2104,626 @@ pipeline_spec_free(struct pipeline_spec *s) memset(s, 0, sizeof(struct pipeline_spec)); } +static const char * +match_type_string_get(enum rte_swx_table_match_type match_type) +{ + switch (match_type) { + case RTE_SWX_TABLE_MATCH_WILDCARD: return "RTE_SWX_TABLE_MATCH_WILDCARD"; + case RTE_SWX_TABLE_MATCH_LPM: return "RTE_SWX_TABLE_MATCH_LPM"; + case RTE_SWX_TABLE_MATCH_EXACT: return "RTE_SWX_TABLE_MATCH_EXACT"; + default: return "RTE_SWX_TABLE_MATCH_UNKNOWN"; + } +} + +void +pipeline_spec_codegen(FILE *f, + struct pipeline_spec *s) +{ + uint32_t i; + + /* Check the input arguments. */ + if (!f || !s) + return; + + /* extobj. */ + fprintf(f, "static struct extobj_spec extobjs[] = {\n"); + + for (i = 0; i < s->n_extobjs; i++) { + struct extobj_spec *extobj_spec = &s->extobjs[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", extobj_spec->name); + fprintf(f, "\t\t.extern_type_name = \"%s\",\n", extobj_spec->extern_type_name); + if (extobj_spec->pragma) + fprintf(f, "\t\t.pragma = \"%s\",\n", extobj_spec->pragma); + else + fprintf(f, "\t\t.pragma = NULL,\n"); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* regarray. */ + fprintf(f, "static struct regarray_spec regarrays[] = {\n"); + + for (i = 0; i < s->n_regarrays; i++) { + struct regarray_spec *regarray_spec = &s->regarrays[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", regarray_spec->name); + fprintf(f, "\t\t.init_val = %" PRIu64 ",\n", regarray_spec->init_val); + fprintf(f, "\t\t.size = %u,\n", regarray_spec->size); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* metarray. */ + fprintf(f, "static struct metarray_spec metarrays[] = {\n"); + + for (i = 0; i < s->n_metarrays; i++) { + struct metarray_spec *metarray_spec = &s->metarrays[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", metarray_spec->name); + fprintf(f, "\t\t.size = %u,\n", metarray_spec->size); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* struct. */ + for (i = 0; i < s->n_structs; i++) { + struct struct_spec *struct_spec = &s->structs[i]; + uint32_t j; + + fprintf(f, "static struct rte_swx_field_params struct_%s_fields[] = {\n", + struct_spec->name); + + for (j = 0; j < struct_spec->n_fields; j++) { + struct rte_swx_field_params *field = &struct_spec->fields[j]; + + fprintf(f, "\t[%d] = {\n", j); + fprintf(f, "\t\t.name = \"%s\",\n", field->name); + fprintf(f, "\t\t.n_bits = %u,\n", field->n_bits); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + } + + fprintf(f, "static struct struct_spec structs[] = {\n"); + + for (i = 0; i < s->n_structs; i++) { + struct struct_spec *struct_spec = &s->structs[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", struct_spec->name); + fprintf(f, "\t\t.fields = struct_%s_fields,\n", struct_spec->name); + fprintf(f, "\t\t.n_fields = " + "sizeof(struct_%s_fields) / sizeof(struct_%s_fields[0]),\n", + struct_spec->name, + struct_spec->name); + fprintf(f, "\t\t.varbit = %d,\n", struct_spec->varbit); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* header. */ + fprintf(f, "static struct header_spec headers[] = {\n"); + + for (i = 0; i < s->n_headers; i++) { + struct header_spec *header_spec = &s->headers[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", header_spec->name); + fprintf(f, "\t\t.struct_type_name = \"%s\",\n", header_spec->struct_type_name); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* metadata. */ + fprintf(f, "static struct metadata_spec metadata[] = {\n"); + + for (i = 0; i < s->n_metadata; i++) { + struct metadata_spec *metadata_spec = &s->metadata[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.struct_type_name = \"%s\",\n", metadata_spec->struct_type_name); + fprintf(f, "\t},\n"); + + } + + fprintf(f, "};\n\n"); + + /* action. */ + for (i = 0; i < s->n_actions; i++) { + struct action_spec *action_spec = &s->actions[i]; + uint32_t j; + + fprintf(f, "static const char *action_%s_initial_instructions[] = {\n", + action_spec->name); + + for (j = 0; j < action_spec->n_instructions; j++) { + const char *instr = action_spec->instructions[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, instr); + } + + fprintf(f, "};\n\n"); + } + + fprintf(f, "static struct action_spec actions[] = {\n"); + + for (i = 0; i < s->n_actions; i++) { + struct action_spec *action_spec = &s->actions[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", action_spec->name); + + if (action_spec->args_struct_type_name) + fprintf(f, "\t\t.args_struct_type_name = \"%s\",\n", + action_spec->args_struct_type_name); + else + fprintf(f, "\t\t.args_struct_type_name = NULL,\n"); + + fprintf(f, "\t\t.instructions = action_%s_initial_instructions,\n", + action_spec->name); + fprintf(f, "\t\t.n_instructions = " + "sizeof(action_%s_initial_instructions) / " + "sizeof(action_%s_initial_instructions[0]),\n", + action_spec->name, + action_spec->name); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* table. */ + for (i = 0; i < s->n_tables; i++) { + struct table_spec *table_spec = &s->tables[i]; + uint32_t j; + + /* fields. */ + if (table_spec->params.fields && table_spec->params.n_fields) { + fprintf(f, "static struct rte_swx_match_field_params " + "table_%s_fields[] = {\n", + table_spec->name); + + for (j = 0; j < table_spec->params.n_fields; j++) { + struct rte_swx_match_field_params *field = + &table_spec->params.fields[j]; + + fprintf(f, "\t[%d] = {\n", j); + fprintf(f, "\t\t.name = \"%s\",\n", field->name); + fprintf(f, "\t\t.match_type = %s,\n", + match_type_string_get(field->match_type)); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + } + + /* action_names. */ + if (table_spec->params.action_names && table_spec->params.n_actions) { + fprintf(f, "static const char *table_%s_action_names[] = {\n", + table_spec->name); + + for (j = 0; j < table_spec->params.n_actions; j++) { + const char *action_name = table_spec->params.action_names[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, action_name); + } + + fprintf(f, "};\n\n"); + } + + /* action_is_for_table_entries. */ + if (table_spec->params.action_is_for_table_entries && + table_spec->params.n_actions) { + fprintf(f, "static int table_%s_action_is_for_table_entries[] = {\n", + table_spec->name); + + for (j = 0; j < table_spec->params.n_actions; j++) { + int value = table_spec->params.action_is_for_table_entries[j]; + + fprintf(f, "\t[%d] = %d,\n", j, value); + } + + fprintf(f, "};\n\n"); + } + + /* action_is_for_default_entry. */ + if (table_spec->params.action_is_for_default_entry && + table_spec->params.n_actions) { + fprintf(f, "static int table_%s_action_is_for_default_entry[] = {\n", + table_spec->name); + + for (j = 0; j < table_spec->params.n_actions; j++) { + int value = table_spec->params.action_is_for_default_entry[j]; + + fprintf(f, "\t[%d] = %d,\n", j, value); + } + + fprintf(f, "};\n\n"); + } + } + + fprintf(f, "static struct table_spec tables[] = {\n"); + + for (i = 0; i < s->n_tables; i++) { + struct table_spec *table_spec = &s->tables[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", table_spec->name); + + fprintf(f, "\t\t.params = {\n"); + + if (table_spec->params.fields && table_spec->params.n_fields) { + fprintf(f, "\t\t\t.fields = table_%s_fields,\n", table_spec->name); + fprintf(f, "\t\t\t.n_fields = " + "sizeof(table_%s_fields) / sizeof(table_%s_fields[0]),\n", + table_spec->name, + table_spec->name); + } else { + fprintf(f, "\t\t\t.fields = NULL,\n"); + fprintf(f, "\t\t\t.n_fields = 0,\n"); + } + + if (table_spec->params.action_names && table_spec->params.n_actions) + fprintf(f, "\t\t\t.action_names = table_%s_action_names,\n", + table_spec->name); + else + fprintf(f, "\t\t\t.action_names = NULL,\n"); + + if (table_spec->params.action_is_for_table_entries && table_spec->params.n_actions) + fprintf(f, "\t\t\t.action_is_for_table_entries = " + "table_%s_action_is_for_table_entries,\n", + table_spec->name); + else + fprintf(f, "\t\t\t.action_is_for_table_entries = NULL,\n"); + + if (table_spec->params.action_is_for_default_entry && table_spec->params.n_actions) + fprintf(f, "\t\t\t.action_is_for_default_entry = " + "table_%s_action_is_for_default_entry,\n", + table_spec->name); + else + fprintf(f, "\t\t\t.action_is_for_default_entry = NULL,\n"); + + if (table_spec->params.n_actions) + fprintf(f, "\t\t\t.n_actions = sizeof(table_%s_action_names) / " + "sizeof(table_%s_action_names[0]),\n", + table_spec->name, + table_spec->name); + else + fprintf(f, "\t\t\t.n_actions = 0,\n"); + + if (table_spec->params.default_action_name) + fprintf(f, "\t\t\t.default_action_name = \"%s\",\n", + table_spec->params.default_action_name); + else + fprintf(f, "\t\t\t.default_action_name = NULL,\n"); + + if (table_spec->params.default_action_args) + fprintf(f, "\t\t\t.default_action_args = \"%s\",\n", + table_spec->params.default_action_args); + else + fprintf(f, "\t\t\t.default_action_args = NULL,\n"); + + fprintf(f, "\t\t\t.default_action_is_const = %d,\n", + table_spec->params.default_action_is_const); + fprintf(f, "\t\t},\n"); + + if (table_spec->recommended_table_type_name) + fprintf(f, "\t\t.recommended_table_type_name = \"%s\",\n", + table_spec->recommended_table_type_name); + else + fprintf(f, "\t\t.recommended_table_type_name = NULL,\n"); + + if (table_spec->args) + fprintf(f, "\t\t.args = \"%s\",\n", table_spec->args); + else + fprintf(f, "\t\t.args = NULL,\n"); + + fprintf(f, "\t\t.size = %u,\n", table_spec->size); + + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* selector. */ + for (i = 0; i < s->n_selectors; i++) { + struct selector_spec *selector_spec = &s->selectors[i]; + uint32_t j; + + if (selector_spec->params.selector_field_names && + selector_spec->params.n_selector_fields) { + fprintf(f, "static const char *selector_%s_field_names[] = {\n", + selector_spec->name); + + for (j = 0; j < selector_spec->params.n_selector_fields; j++) { + const char *field_name = + selector_spec->params.selector_field_names[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, field_name); + } + + fprintf(f, "};\n\n"); + } + } + + fprintf(f, "static struct selector_spec selectors[] = {\n"); + + for (i = 0; i < s->n_selectors; i++) { + struct selector_spec *selector_spec = &s->selectors[i]; + + fprintf(f, "\t[%d] = {\n", i); + + fprintf(f, "\t\t.name = \"%s\",\n", selector_spec->name); + fprintf(f, "\t\t.params = {\n"); + + if (selector_spec->params.group_id_field_name) + fprintf(f, "\t\t\t.group_id_field_name = \"%s\",\n", + selector_spec->params.group_id_field_name); + else + fprintf(f, "\t\t\t.group_id_field_name = NULL,\n"); + + if (selector_spec->params.selector_field_names && + selector_spec->params.n_selector_fields) { + fprintf(f, "\t\t\t.selector_field_names = selector_%s_field_names,\n", + selector_spec->name); + fprintf(f, "\t\t\t.n_selector_fields = " + "sizeof(selector_%s_field_names) / sizeof(selector_%s_field_names[0]),\n", + selector_spec->name, + selector_spec->name); + } else { + fprintf(f, "\t\t\t.selector_field_names = NULL,\n"); + fprintf(f, "\t\t\t.n_selector_fields = 0,\n"); + } + + if (selector_spec->params.member_id_field_name) + fprintf(f, "\t\t\t.member_id_field_name = \"%s\",\n", + selector_spec->params.member_id_field_name); + else + fprintf(f, "\t\t\t.member_id_field_name = NULL,\n"); + + fprintf(f, "\t\t\t.n_groups_max = %u,\n", selector_spec->params.n_groups_max); + + fprintf(f, "\t\t\t.n_members_per_group_max = %u,\n", + selector_spec->params.n_members_per_group_max); + + fprintf(f, "\t\t},\n"); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* learner. */ + for (i = 0; i < s->n_learners; i++) { + struct learner_spec *learner_spec = &s->learners[i]; + uint32_t j; + + /* field_names. */ + if (learner_spec->params.field_names && learner_spec->params.n_fields) { + fprintf(f, "static const char *learner_%s_field_names[] = {\n", + learner_spec->name); + + for (j = 0; j < learner_spec->params.n_fields; j++) { + const char *field_name = learner_spec->params.field_names[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, field_name); + } + + fprintf(f, "};\n\n"); + } + + /* action_names. */ + if (learner_spec->params.action_names && learner_spec->params.n_actions) { + fprintf(f, "static const char *learner_%s_action_names[] = {\n", + learner_spec->name); + + for (j = 0; j < learner_spec->params.n_actions; j++) { + const char *action_name = learner_spec->params.action_names[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, action_name); + } + + fprintf(f, "};\n\n"); + } + + /* action_is_for_table_entries. */ + if (learner_spec->params.action_is_for_table_entries && + learner_spec->params.n_actions) { + fprintf(f, "static int learner_%s_action_is_for_table_entries[] = {\n", + learner_spec->name); + + for (j = 0; j < learner_spec->params.n_actions; j++) { + int value = learner_spec->params.action_is_for_table_entries[j]; + + fprintf(f, "\t[%d] = %d,\n", j, value); + } + + fprintf(f, "};\n\n"); + } + + /* action_is_for_default_entry. */ + if (learner_spec->params.action_is_for_default_entry && + learner_spec->params.n_actions) { + fprintf(f, "static int learner_%s_action_is_for_default_entry[] = {\n", + learner_spec->name); + + for (j = 0; j < learner_spec->params.n_actions; j++) { + int value = learner_spec->params.action_is_for_default_entry[j]; + + fprintf(f, "\t[%d] = %d,\n", j, value); + } + + fprintf(f, "};\n\n"); + } + + /* timeout. */ + if (learner_spec->timeout && learner_spec->n_timeouts) { + fprintf(f, "static uint32_t learner_%s_timeout[] = {\n", learner_spec->name); + + for (j = 0; j < learner_spec->n_timeouts; j++) { + uint32_t value = learner_spec->timeout[j]; + + fprintf(f, "\t[%d] = %u,\n", j, value); + } + + fprintf(f, "};\n\n"); + } + } + + fprintf(f, "static struct learner_spec learners[] = {\n"); + + for (i = 0; i < s->n_learners; i++) { + struct learner_spec *learner_spec = &s->learners[i]; + + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t\t.name = \"%s\",\n", learner_spec->name); + + fprintf(f, "\t\t.params = {\n"); + + if (learner_spec->params.field_names && learner_spec->params.n_fields) { + fprintf(f, "\t\t\t.field_names = learner_%s_field_names,\n", + learner_spec->name); + fprintf(f, "\t\t\t.n_fields = " + "sizeof(learner_%s_field_names) / " + "sizeof(learner_%s_field_names[0]),\n", + learner_spec->name, + learner_spec->name); + } else { + fprintf(f, "\t\t\t.field_names = NULL,\n"); + fprintf(f, "\t\t\t.n_fields = 0,\n"); + } + + if (learner_spec->params.action_names && learner_spec->params.n_actions) + fprintf(f, "\t\t\t.action_names = learner_%s_action_names,\n", + learner_spec->name); + else + fprintf(f, "\t\t\t.action_names = NULL,\n"); + + if (learner_spec->params.action_is_for_table_entries && + learner_spec->params.n_actions) + fprintf(f, "\t\t\t.action_is_for_table_entries = " + "learner_%s_action_is_for_table_entries,\n", + learner_spec->name); + else + fprintf(f, "\t\t\t.action_is_for_table_entries = NULL,\n"); + + if (learner_spec->params.action_is_for_default_entry && + learner_spec->params.n_actions) + fprintf(f, "\t\t\t.action_is_for_default_entry = " + "learner_%s_action_is_for_default_entry,\n", + learner_spec->name); + else + fprintf(f, "\t\t\t.action_is_for_default_entry = NULL,\n"); + + if (learner_spec->params.action_names && learner_spec->params.n_actions) + fprintf(f, "\t\t\t.n_actions = " + "sizeof(learner_%s_action_names) / sizeof(learner_%s_action_names[0]),\n", + learner_spec->name, + learner_spec->name); + else + fprintf(f, "\t\t\t.n_actions = NULL,\n"); + + if (learner_spec->params.default_action_name) + fprintf(f, "\t\t\t.default_action_name = \"%s\",\n", + learner_spec->params.default_action_name); + else + fprintf(f, "\t\t\t.default_action_name = NULL,\n"); + + if (learner_spec->params.default_action_args) + fprintf(f, "\t\t\t.default_action_args = \"%s\",\n", + learner_spec->params.default_action_args); + else + fprintf(f, "\t\t\t.default_action_args = NULL,\n"); + + fprintf(f, "\t\t\t.default_action_is_const = %d,\n", + learner_spec->params.default_action_is_const); + + fprintf(f, "\t\t},\n"); + + fprintf(f, "\t\t.size = %u,\n", learner_spec->size); + + if (learner_spec->timeout && learner_spec->n_timeouts) { + fprintf(f, "\t\t.timeout = learner_%s_timeout,\n", learner_spec->name); + fprintf(f, "\t\t\t.n_timeouts = " + "sizeof(learner_%s_timeout) / sizeof(learner_%s_timeout[0]),\n", + learner_spec->name, + learner_spec->name); + } else { + fprintf(f, "\t\t.timeout = NULL,\n"); + fprintf(f, "\t\t\t.n_timeouts = 0,\n"); + } + + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* apply. */ + for (i = 0; i < s->n_apply; i++) { + struct apply_spec *apply_spec = &s->apply[i]; + uint32_t j; + + fprintf(f, "static const char *apply%u_initial_instructions[] = {\n", i); + + for (j = 0; j < apply_spec->n_instructions; j++) { + const char *instr = apply_spec->instructions[j]; + + fprintf(f, "\t[%d] = \"%s\",\n", j, instr); + } + + fprintf(f, "};\n\n"); + } + + fprintf(f, "static struct apply_spec apply[] = {\n"); + + for (i = 0; i < s->n_apply; i++) { + fprintf(f, "\t[%d] = {\n", i); + fprintf(f, "\t.instructions = apply%u_initial_instructions,\n", i); + fprintf(f, "\t.n_instructions = " + "sizeof(apply%u_initial_instructions) / " + "sizeof(apply%u_initial_instructions[0]),\n", + i, + i); + fprintf(f, "\t},\n"); + } + + fprintf(f, "};\n\n"); + + /* pipeline. */ + fprintf(f, "struct pipeline_spec pipeline_spec = {\n"); + fprintf(f, "\t.extobjs = extobjs,\n"); + fprintf(f, "\t.structs = structs,\n"); + fprintf(f, "\t.headers = headers,\n"); + fprintf(f, "\t.metadata = metadata,\n"); + fprintf(f, "\t.actions = actions,\n"); + fprintf(f, "\t.tables = tables,\n"); + fprintf(f, "\t.selectors = selectors,\n"); + fprintf(f, "\t.learners = learners,\n"); + fprintf(f, "\t.regarrays = regarrays,\n"); + fprintf(f, "\t.metarrays = metarrays,\n"); + fprintf(f, "\t.apply = apply,\n"); + fprintf(f, "\t.n_extobjs = sizeof(extobjs) / sizeof(extobjs[0]),\n"); + fprintf(f, "\t.n_structs = sizeof(structs) / sizeof(structs[0]),\n"); + fprintf(f, "\t.n_headers = sizeof(headers) / sizeof(headers[0]),\n"); + fprintf(f, "\t.n_metadata = sizeof(metadata) / sizeof(metadata[0]),\n"); + fprintf(f, "\t.n_actions = sizeof(actions) / sizeof(actions[0]),\n"); + fprintf(f, "\t.n_tables = sizeof(tables) / sizeof(tables[0]),\n"); + fprintf(f, "\t.n_selectors = sizeof(selectors) / sizeof(selectors[0]),\n"); + fprintf(f, "\t.n_learners = sizeof(learners) / sizeof(learners[0]),\n"); + fprintf(f, "\t.n_regarrays = sizeof(regarrays) / sizeof(regarrays[0]),\n"); + fprintf(f, "\t.n_metarrays = sizeof(metarrays) / sizeof(metarrays[0]),\n"); + fprintf(f, "\t.n_apply = sizeof(apply) / sizeof(apply[0]),\n"); + fprintf(f, "};\n"); +} + struct pipeline_spec * pipeline_spec_parse(FILE *spec, uint32_t *err_line, diff --git a/lib/pipeline/rte_swx_pipeline_spec.h b/lib/pipeline/rte_swx_pipeline_spec.h index 4f3a0b5958..707b99ba09 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.h +++ b/lib/pipeline/rte_swx_pipeline_spec.h @@ -206,6 +206,11 @@ struct pipeline_spec { void pipeline_spec_free(struct pipeline_spec *s); + +void +pipeline_spec_codegen(FILE *f, + struct pipeline_spec *s); + struct pipeline_spec * pipeline_spec_parse(FILE *spec, uint32_t *err_line, From patchwork Mon Jul 18 13:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114021 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97C69A0032; Mon, 18 Jul 2022 15:07:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB18142B87; Mon, 18 Jul 2022 15:07:24 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C653F40041 for ; Mon, 18 Jul 2022 15:07:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149641; x=1689685641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2xtKH5YwBNH0YtSD96L/IjrRVQtxD+BIloqcSzc/ybk=; b=lNY8Vi1tMKrKjmiLU0ga1Alh9n/9KDk2ktvI9R5fOoobeyrfgSwU12lf dQpS6iR8WMjLw9848Ggv84rSJ+B1+HkzY8C8NI1O6K/7q8wVl8Xl+tpWv 1UkX0/lx8qVegXX3pOW/oPzBLc8XsUqHUy41hKIH3zvIX75Df22C2Vwl/ 2qNxftYF2kicdVU0y14jNaaDpTCMBZ1LCuirNf4KW7sqtMWIEgzrW6Jgt fBXAWW0J8gYsdY+ge0NkpPaixnaEAovnojNHicen8yJdK7bSUg9rHw0u7 5FgK3AHagTEDOPdAuGlgIDuUoDA5BG6PXUso3fMFnC1B40s9cbuhyXGqD A==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996424" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996424" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459744" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:18 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 5/9] pipeline: add API for pipeline code generation Date: Mon, 18 Jul 2022 13:07:09 +0000 Message-Id: <20220718130713.339003-5-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Previously, the C code generation for the pipeline was hidden under the hood; now, we make this an explicit API operation. Besides the functions for the pipeline actions and the pipeline instructions, the generated C source code now includes the pipeline specification structure required for the pipeline configuration operations. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- lib/pipeline/rte_swx_pipeline.c | 94 +++++++++++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline.h | 25 +++++++++ lib/pipeline/version.map | 3 ++ 3 files changed, 122 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 3e1c6e9edb..52760111fd 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -18,6 +18,7 @@ #include #include "rte_swx_pipeline_internal.h" +#include "rte_swx_pipeline_spec.h" #define CHECK(condition, err_code) \ do { \ @@ -13476,3 +13477,96 @@ pipeline_compile(struct rte_swx_pipeline *p) return status; } + +int +rte_swx_pipeline_codegen(FILE *spec_file, + FILE *code_file, + uint32_t *err_line, + const char **err_msg) + +{ + struct rte_swx_pipeline *p = NULL; + struct pipeline_spec *s = NULL; + struct instruction_group_list *igl = NULL; + struct action *a; + int status = 0; + + /* Check input arguments. */ + if (!spec_file || !code_file) { + if (err_line) + *err_line = 0; + if (err_msg) + *err_msg = "Invalid input argument."; + status = -EINVAL; + goto free; + } + + /* Pipeline configuration. */ + s = pipeline_spec_parse(spec_file, err_line, err_msg); + if (!s) { + status = -EINVAL; + goto free; + } + + status = rte_swx_pipeline_config(&p, 0); + if (status) { + if (err_line) + *err_line = 0; + if (err_msg) + *err_msg = "Pipeline configuration error."; + goto free; + } + + status = pipeline_spec_configure(p, s, err_msg); + if (status) { + if (err_line) + *err_line = 0; + goto free; + } + + /* + * Pipeline code generation. + */ + + /* Instruction Group List (IGL) computation: the pipeline configuration must be done first, + * but there is no need for the pipeline build to be done as well. + */ + igl = instruction_group_list_create(p); + if (!igl) { + if (err_line) + *err_line = 0; + if (err_msg) + *err_msg = "Memory allocation failed."; + status = -ENOMEM; + goto free; + } + + /* Header file inclusion. */ + fprintf(code_file, "#include \"rte_swx_pipeline_internal.h\"\n"); + fprintf(code_file, "#include \"rte_swx_pipeline_spec.h\"\n\n"); + + /* Code generation for the pipeline specification. */ + pipeline_spec_codegen(code_file, s); + fprintf(code_file, "\n"); + + /* Code generation for the action instructions. */ + TAILQ_FOREACH(a, &p->actions, node) { + fprintf(code_file, "/**\n * Action %s\n */\n\n", a->name); + + action_data_codegen(a, code_file); + fprintf(code_file, "\n"); + + action_instr_codegen(a, code_file); + fprintf(code_file, "\n"); + } + + /* Code generation for the pipeline instructions. */ + instruction_group_list_codegen(igl, p, code_file); + +free: + instruction_group_list_free(igl); + rte_swx_pipeline_free(p); + pipeline_spec_free(s); + + return status; +} diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index c41ca5cb15..2bd019b05f 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -941,6 +941,31 @@ __rte_experimental int rte_swx_pipeline_build(struct rte_swx_pipeline *p); +/** + * Pipeline C code generate based on input specification file + * + * @param[in] spec_file + * Pipeline specification file (.spec) provided as input. + * @param[in] code_file + * Pipeline C language file (.c) to be generated. + * @param[out] err_line + * In case of error and non-NULL, the line number within the *spec* file where + * the error occurred. The first line number in the file is 1. + * @param[out] err_msg + * In case of error and non-NULL, the error message. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument; + * -ENOMEM: Not enough space/cannot allocate memory; + * -EEXIST: Resource with the same name already exists. + */ +__rte_experimental +int +rte_swx_pipeline_codegen(FILE *spec_file, + FILE *code_file, + uint32_t *err_line, + const char **err_msg); + /** * Pipeline build from specification file * diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map index 8312307a7a..51165d48cf 100644 --- a/lib/pipeline/version.map +++ b/lib/pipeline/version.map @@ -145,4 +145,7 @@ EXPERIMENTAL { rte_swx_ctl_pipeline_learner_timeout_get; rte_swx_ctl_pipeline_learner_timeout_set; rte_swx_pipeline_hash_func_register; + + #added in 22.11 + rte_swx_pipeline_codegen; }; From patchwork Mon Jul 18 13:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114022 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E6A38A0032; Mon, 18 Jul 2022 15:07:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A67F42B84; Mon, 18 Jul 2022 15:07:25 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 7B3A0410F6 for ; Mon, 18 Jul 2022 15:07:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149641; x=1689685641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+zaWrZ6jg3mB7NTkUZXF6M77ikfoX75BIM356AZQXA4=; b=YbfwW7RWMDV6dF0MvWOOtlmekvRj/HMbDKxHeVPvQG+FwLt449qXa1wd 1HsNxarew6r1zKJwDp3lvmg9rIdjLurL5uI1jBnleVrTNU0P0q7iEH9X0 yUb67Op37JnVQeD3q2OQKnRmW+kZo6b0HGP6Lg082am7ayPRN97kXip1N rMmfx9FttI7rax6TUzlm7WWO1qBB/BTDLpvy7tKORtvVtKcm9wYv2Goph yfY+1W1ncpOQrhiVfFebCXsftQWhzX2tRs0Ulix3Q1m/LVnlMMVkZm9nN EwcAF7r78hzvXJQSIxPmx9R8HlW9BSQNXbhdzPXmPY2/i16TWq6YYggwr g==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996432" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996432" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459750" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:19 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 6/9] pipeline: add API for shared library-based pipeline build Date: Mon, 18 Jul 2022 13:07:10 +0000 Message-Id: <20220718130713.339003-6-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Previously, the pipeline build operation was done based on the specification file (typically produced by the P4 compiler), then the C code with optimized functions for the pipeline actions and instructions was generated, built into a shared object library, loaded and installed into the pipeline in a completely hardcoded and non-customizable way. Now, this process is split into three explicit stages: i) code generation (specification file -> C file); ii) code build (C file -> shared object library); iii) code installation (library load into the pipeline). Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 20 +- lib/pipeline/rte_swx_pipeline.c | 289 +++++++++------------------ lib/pipeline/rte_swx_pipeline.h | 22 +- lib/pipeline/rte_swx_pipeline_spec.c | 51 ----- lib/pipeline/version.map | 2 +- 5 files changed, 108 insertions(+), 276 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index ad553f19ab..1f75b5dc9d 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -984,7 +984,7 @@ cmd_pipeline_port_out(char **tokens, } static const char cmd_pipeline_build_help[] = -"pipeline build \n"; +"pipeline build \n"; static void cmd_pipeline_build(char **tokens, @@ -994,9 +994,6 @@ cmd_pipeline_build(char **tokens, void *obj) { struct pipeline *p = NULL; - FILE *spec = NULL; - uint32_t err_line; - const char *err_msg; int status; if (n_tokens != 4) { @@ -1010,20 +1007,9 @@ cmd_pipeline_build(char **tokens, return; } - spec = fopen(tokens[3], "r"); - if (!spec) { - snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]); - return; - } - - status = rte_swx_pipeline_build_from_spec(p->p, - spec, - &err_line, - &err_msg); - fclose(spec); + status = rte_swx_pipeline_build_from_lib(p->p, tokens[3]); if (status) { - snprintf(out, out_size, "Error %d at line %u: %s\n.", - status, err_line, err_msg); + snprintf(out, out_size, "Pipeline build error (%d).", status); return; } diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 52760111fd..03414bfd1f 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -9807,9 +9807,6 @@ rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p, return 0; } -static int -pipeline_compile(struct rte_swx_pipeline *p); - int rte_swx_pipeline_build(struct rte_swx_pipeline *p) { @@ -9899,8 +9896,6 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p) p->build_done = 1; - pipeline_compile(p); - return 0; error: @@ -13222,160 +13217,6 @@ instruction_group_list_custom_instructions_count(struct instruction_group_list * return n_custom_instr; } -static int -pipeline_codegen(struct rte_swx_pipeline *p, struct instruction_group_list *igl) -{ - struct action *a; - FILE *f = NULL; - - /* Create the .c file. */ - f = fopen("/tmp/pipeline.c", "w"); - if (!f) - return -EIO; - - /* Include the .h file. */ - fprintf(f, "#include \"rte_swx_pipeline_internal.h\"\n"); - - /* Add the code for each action. */ - TAILQ_FOREACH(a, &p->actions, node) { - fprintf(f, "/**\n * Action %s\n */\n\n", a->name); - - action_data_codegen(a, f); - - fprintf(f, "\n"); - - action_instr_codegen(a, f); - - fprintf(f, "\n"); - } - - /* Add the pipeline code. */ - instruction_group_list_codegen(igl, p, f); - - /* Close the .c file. */ - fclose(f); - - return 0; -} - -#ifndef RTE_SWX_PIPELINE_CMD_MAX_SIZE -#define RTE_SWX_PIPELINE_CMD_MAX_SIZE 4096 -#endif - -static int -pipeline_libload(struct rte_swx_pipeline *p, struct instruction_group_list *igl) -{ - struct action *a; - struct instruction_group *g; - char *dir_in, *buffer = NULL; - const char *dir_out; - int status = 0; - - /* Get the environment variables. */ - dir_in = getenv("RTE_INSTALL_DIR"); - if (!dir_in) { - status = -EINVAL; - goto free; - } - - dir_out = "/tmp"; - - /* Memory allocation for the command buffer. */ - buffer = malloc(RTE_SWX_PIPELINE_CMD_MAX_SIZE); - if (!buffer) { - status = -ENOMEM; - goto free; - } - - snprintf(buffer, - RTE_SWX_PIPELINE_CMD_MAX_SIZE, - "gcc -c -O3 -fpic -Wno-deprecated-declarations -o %s/pipeline.o %s/pipeline.c " - "-I %s/lib/pipeline " - "-I %s/lib/eal/include " - "-I %s/lib/eal/x86/include " - "-I %s/lib/eal/include/generic " - "-I %s/lib/meter " - "-I %s/lib/port " - "-I %s/lib/table " - "-I %s/lib/pipeline " - "-I %s/config " - "-I %s/build " - "-I %s/lib/eal/linux/include " - ">%s/pipeline.log 2>&1 " - "&& " - "gcc -shared %s/pipeline.o -o %s/libpipeline.so " - ">>%s/pipeline.log 2>&1", - dir_out, - dir_out, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_in, - dir_out, - dir_out, - dir_out, - dir_out); - - /* Build the shared object library. */ - status = system(buffer); - if (status) - goto free; - - /* Open library. */ - snprintf(buffer, - RTE_SWX_PIPELINE_CMD_MAX_SIZE, - "%s/libpipeline.so", - dir_out); - - p->lib = dlopen(buffer, RTLD_LAZY); - if (!p->lib) { - status = -EIO; - goto free; - } - - /* Get the action function symbols. */ - TAILQ_FOREACH(a, &p->actions, node) { - snprintf(buffer, RTE_SWX_PIPELINE_CMD_MAX_SIZE, "action_%s_run", a->name); - - p->action_funcs[a->id] = dlsym(p->lib, buffer); - if (!p->action_funcs[a->id]) { - status = -EINVAL; - goto free; - } - } - - /* Get the pipeline function symbols. */ - TAILQ_FOREACH(g, igl, node) { - if (g->first_instr_id == g->last_instr_id) - continue; - - snprintf(buffer, RTE_SWX_PIPELINE_CMD_MAX_SIZE, "pipeline_func_%u", g->group_id); - - g->func = dlsym(p->lib, buffer); - if (!g->func) { - status = -EINVAL; - goto free; - } - } - -free: - if (status && p->lib) { - dlclose(p->lib); - p->lib = NULL; - } - - free(buffer); - - return status; -} - static int pipeline_adjust_check(struct rte_swx_pipeline *p __rte_unused, struct instruction_group_list *igl) @@ -13443,41 +13284,6 @@ pipeline_adjust(struct rte_swx_pipeline *p, struct instruction_group_list *igl) instr_jmp_resolve(p->instructions, p->instruction_data, p->n_instructions); } -static int -pipeline_compile(struct rte_swx_pipeline *p) -{ - struct instruction_group_list *igl = NULL; - int status = 0; - - igl = instruction_group_list_create(p); - if (!igl) { - status = -ENOMEM; - goto free; - } - - /* Code generation. */ - status = pipeline_codegen(p, igl); - if (status) - goto free; - - /* Build and load the shared object library. */ - status = pipeline_libload(p, igl); - if (status) - goto free; - - /* Adjust instructions. */ - status = pipeline_adjust_check(p, igl); - if (status) - goto free; - - pipeline_adjust(p, igl); - -free: - instruction_group_list_free(igl); - - return status; -} - int rte_swx_pipeline_codegen(FILE *spec_file, FILE *code_file, @@ -13570,3 +13376,98 @@ rte_swx_pipeline_codegen(FILE *spec_file, return status; } + +int +rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline *p, + const char *lib_file_name) +{ + void *lib = NULL; + struct pipeline_spec *s = NULL; + struct instruction_group_list *igl = NULL; + struct action *a; + struct instruction_group *g; + int status = 0; + + /* Check input arguments. */ + if (!p || p->build_done || !lib_file_name || !lib_file_name[0]) { + status = -EINVAL; + goto free; + } + + /* Open the library. */ + lib = dlopen(lib_file_name, RTLD_LAZY); + if (!lib) { + status = -EIO; + goto free; + } + + /* Get the pipeline specification structure from the library. */ + s = dlsym(lib, "pipeline_spec"); + if (!s) { + status = -EINVAL; + goto free; + } + + /* Pipeline configuration based on the specification structure. */ + status = pipeline_spec_configure(p, s, NULL); + if (status) + goto free; + + /* Pipeline build. */ + status = rte_swx_pipeline_build(p); + if (status) + goto free; + + /* Action instructions. */ + TAILQ_FOREACH(a, &p->actions, node) { + char name[RTE_SWX_NAME_SIZE * 2]; + + snprintf(name, sizeof(name), "action_%s_run", a->name); + + p->action_funcs[a->id] = dlsym(lib, name); + if (!p->action_funcs[a->id]) { + status = -EINVAL; + goto free; + } + } + + /* Pipeline instructions. */ + igl = instruction_group_list_create(p); + if (!igl) { + status = -ENOMEM; + goto free; + } + + TAILQ_FOREACH(g, igl, node) { + char name[RTE_SWX_NAME_SIZE * 2]; + + if (g->first_instr_id == g->last_instr_id) + continue; + + snprintf(name, sizeof(name), "pipeline_func_%u", g->group_id); + + g->func = dlsym(lib, name); + if (!g->func) { + status = -EINVAL; + goto free; + } + } + + status = pipeline_adjust_check(p, igl); + if (status) + goto free; + + pipeline_adjust(p, igl); + + p->lib = lib; + +free: + if (status && lib) { + dlclose(lib); + p->lib = NULL; + } + + instruction_group_list_free(igl); + + return status; +} diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index 2bd019b05f..cb834cd64d 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -967,30 +967,26 @@ rte_swx_pipeline_codegen(FILE *spec_file, const char **err_msg); /** - * Pipeline build from specification file + * Pipeline build from shared object library + * + * The shared object library must be built from the C language source code file + * previously generated by the rte_swx_pipeline_codegen() API function. * * @param[in] p * Pipeline handle. - * @param[in] spec - * Pipeline specification file. - * @param[out] err_line - * In case of error and non-NULL, the line number within the *spec* file where - * the error occurred. The first line number in the file is 1. - * @param[out] err_msg - * In case of error and non-NULL, the error message. + * @param[in] lib_file_name + * Shared object library file name. * @return * 0 on success or the following error codes otherwise: * -EINVAL: Invalid argument; * -ENOMEM: Not enough space/cannot allocate memory; - * -EEXIST: Resource with the same name already exists; + * -EEXIST: Pipeline was already built successfully; * -ENODEV: Extern object or table creation error. */ __rte_experimental int -rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, - FILE *spec, - uint32_t *err_line, - const char **err_msg); +rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline *p, + const char *lib_file_name); /** * Pipeline run diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index 05cf952816..206b514856 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.c +++ b/lib/pipeline/rte_swx_pipeline_spec.c @@ -3514,54 +3514,3 @@ pipeline_spec_configure(struct rte_swx_pipeline *p, return 0; } - -int -rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, - FILE *spec_file, - uint32_t *err_line, - const char **err_msg) -{ - struct pipeline_spec *s = NULL; - int status = 0; - - /* Check the input arguments. */ - if (!p || !spec_file) { - if (err_line) - *err_line = 0; - if (err_msg) - *err_msg = "Invalid input argument."; - status = -EINVAL; - goto error; - } - - /* Spec file parse. */ - s = pipeline_spec_parse(spec_file, err_line, err_msg); - if (!s) { - status = -EINVAL; - goto error; - } - - /* Pipeline configure. */ - status = pipeline_spec_configure(p, s, err_msg); - if (status) { - if (err_line) - *err_line = 0; - goto error; - } - - /* Pipeline build. */ - status = rte_swx_pipeline_build(p); - if (status) { - if (err_line) - *err_line = 0; - if (err_msg) - *err_msg = "Pipeline build error."; - goto error; - } - - return 0; - -error: - pipeline_spec_free(s); - return status; -} diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map index 51165d48cf..810cc56467 100644 --- a/lib/pipeline/version.map +++ b/lib/pipeline/version.map @@ -82,7 +82,6 @@ EXPERIMENTAL { rte_swx_ctl_table_ops_get; rte_swx_pipeline_action_config; rte_swx_pipeline_build; - rte_swx_pipeline_build_from_spec; rte_swx_pipeline_config; rte_swx_pipeline_extern_func_register; rte_swx_pipeline_extern_object_config; @@ -148,4 +147,5 @@ EXPERIMENTAL { #added in 22.11 rte_swx_pipeline_codegen; + rte_swx_pipeline_build_from_lib; }; From patchwork Mon Jul 18 13:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114023 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 492A0A0032; Mon, 18 Jul 2022 15:08:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0B0242B75; Mon, 18 Jul 2022 15:07:26 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 4F48C410F6 for ; Mon, 18 Jul 2022 15:07:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149642; x=1689685642; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vacxN6cH9lLaCOfqCfExiK8CHho7BmHRQbeaEUUPfVA=; b=ebxi4QxbVw8aWh8bq51kpXg/S90assWAkrlTCB9OtGSYsBy5Qgwvxx8L TAxEmrVhQjtyuf+It6vez+O8ysqHSlpfUDOF1JT4ijY7yGIpFDfTzV/mU NEJKLbzgwjTFhFNkXIIJRoGYuyh7L9a/ojEgkqSApeEFXTNMnmdRgHHoJ mLHQoHahhz1s4tpfpq0Ld4RQP4opQb8ynflWPZ9U883ICRR9MdLsoRYu3 MRYeZg0xKQW+JJt21xvp+YJHFuaF4dESxOUzUjYndp4AKUlMz/T6Phn3q vHcV5ju0LPP3AaxkoQZcdrryG1VXSoQXC3W8nNf3hGAKh6fs4NCXIvek/ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996439" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996439" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459756" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:20 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 7/9] examples/pipeline: add CLI command for pipeline code generation Date: Mon, 18 Jul 2022 13:07:11 +0000 Message-Id: <20220718130713.339003-7-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add CLI command for the pipeline code generation operation. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 1f75b5dc9d..fdaf5dd16b 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -983,6 +983,53 @@ cmd_pipeline_port_out(char **tokens, } } +static const char cmd_pipeline_codegen_help[] = +"pipeline codegen \n"; + +static void +cmd_pipeline_codegen(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj __rte_unused) +{ + FILE *spec_file = NULL; + FILE *code_file = NULL; + uint32_t err_line; + const char *err_msg; + int status; + + if (n_tokens != 4) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + spec_file = fopen(tokens[2], "r"); + if (!spec_file) { + snprintf(out, out_size, "Cannot open file %s.\n", tokens[2]); + return; + } + + code_file = fopen(tokens[3], "w"); + if (!code_file) { + snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]); + return; + } + + status = rte_swx_pipeline_codegen(spec_file, + code_file, + &err_line, + &err_msg); + + fclose(spec_file); + fclose(code_file); + + if (status) { + snprintf(out, out_size, "Error %d at line %u: %s\n.", + status, err_line, err_msg); + return; + } +} static const char cmd_pipeline_build_help[] = "pipeline build \n"; @@ -2962,6 +3009,7 @@ cmd_help(char **tokens, "\tpipeline create\n" "\tpipeline port in\n" "\tpipeline port out\n" + "\tpipeline codegen\n" "\tpipeline build\n" "\tpipeline table add\n" "\tpipeline table delete\n" @@ -3031,6 +3079,12 @@ cmd_help(char **tokens, } } + if ((strcmp(tokens[0], "pipeline") == 0) && + (n_tokens == 2) && (strcmp(tokens[1], "codegen") == 0)) { + snprintf(out, out_size, "\n%s\n", cmd_pipeline_codegen_help); + return; + } + if ((strcmp(tokens[0], "pipeline") == 0) && (n_tokens == 2) && (strcmp(tokens[1], "build") == 0)) { snprintf(out, out_size, "\n%s\n", cmd_pipeline_build_help); @@ -3309,6 +3363,13 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } + if ((n_tokens >= 3) && + (strcmp(tokens[1], "codegen") == 0)) { + cmd_pipeline_codegen(tokens, n_tokens, out, out_size, + obj); + return; + } + if ((n_tokens >= 3) && (strcmp(tokens[2], "build") == 0)) { cmd_pipeline_build(tokens, n_tokens, out, out_size, From patchwork Mon Jul 18 13:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114024 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5F625A0032; Mon, 18 Jul 2022 15:08:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BDE2842B91; Mon, 18 Jul 2022 15:07:27 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 11D9842826 for ; Mon, 18 Jul 2022 15:07:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149643; x=1689685643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UKOeBB4jfHy8qzsuk44emkAEXr1Jv/Z0+d4QN/W5qSQ=; b=D22ySoLd3fBrr9v4thAZgDRmOZmENvBRjxlo22DrWQjtFvJ4o1pDUYTq GsDIz14u/zJIcH4OVEDyeKlc4oDWqzzkaw3c1FZlluwc6GJXxcrchZFcp 5Onhspao8YvtlPePm6TR1Ll7WB1AQBw9NKitkY9LL5116IUrZNnngEOHp nRzOj9mmSfYqeze6fvtniOBsUwI19IFffiShdJTFgw92eo8IjBl7ykKqX Pn9GkBTyIi4F3v2i82a+vCwKll+nsRb1oc9rPufNUkIlN0Nd/5lqhVFNi dk8cCPLxcsz3Ado4Nr+0SpzlZtiZw+gR893tKKCRE6WyNTPJyHcfSMf9H g==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996443" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996443" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459762" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:21 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 8/9] examples/pipeline: add CLI command for shared library build Date: Mon, 18 Jul 2022 13:07:12 +0000 Message-Id: <20220718130713.339003-8-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add CLI command for the shared object library build operation. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 147 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 4 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index fdaf5dd16b..f1d2fbf52d 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,10 @@ #define CMD_MAX_TOKENS 256 #endif +#ifndef MAX_LINE_SIZE +#define MAX_LINE_SIZE 2048 +#endif + #define MSG_OUT_OF_MEMORY "Not enough memory.\n" #define MSG_CMD_UNKNOWN "Unknown command \"%s\".\n" #define MSG_CMD_UNIMPLEM "Command \"%s\" not implemented.\n" @@ -1030,6 +1035,130 @@ cmd_pipeline_codegen(char **tokens, return; } } + +static const char cmd_pipeline_libbuild_help[] = +"pipeline libbuild \n"; + +static void +cmd_pipeline_libbuild(char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size, + void *obj __rte_unused) +{ + char *code_file, *lib_file, *obj_file = NULL, *log_file = NULL; + char *install_dir, *buffer = NULL; + size_t length; + int status = 0; + + if (n_tokens != 4) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + goto free; + } + + install_dir = getenv("RTE_INSTALL_DIR"); + if (!install_dir) { + snprintf(out, out_size, "Error: Environment variable RTE_INSTALL_DIR is not set."); + return; + } + + snprintf(out, out_size, "Using DPDK source code from \"%s\".\n", install_dir); + out_size -= strlen(out); + out += strlen(out); + + code_file = tokens[2]; + length = strnlen(code_file, MAX_LINE_SIZE); + if ((length < 3) || + (code_file[length - 2] != '.') || + (code_file[length - 1] != 'c')) { + snprintf(out, out_size, MSG_ARG_INVALID, "code_file"); + goto free; + } + + lib_file = tokens[3]; + length = strnlen(lib_file, MAX_LINE_SIZE); + if ((length < 4) || + (lib_file[length - 3] != '.') || + (lib_file[length - 2] != 's') || + (lib_file[length - 1] != 'o')) { + snprintf(out, out_size, MSG_ARG_INVALID, "lib_file"); + goto free; + } + + obj_file = malloc(length); + log_file = malloc(length + 2); + if (!obj_file || !log_file) { + snprintf(out, out_size, MSG_OUT_OF_MEMORY); + goto free; + } + + memcpy(obj_file, lib_file, length - 2); + obj_file[length - 2] = 'o'; + obj_file[length - 1] = 0; + + memcpy(log_file, lib_file, length - 2); + log_file[length - 2] = 'l'; + log_file[length - 1] = 'o'; + log_file[length] = 'g'; + log_file[length + 1] = 0; + + buffer = malloc(MAX_LINE_SIZE); + if (!buffer) { + snprintf(out, out_size, MSG_OUT_OF_MEMORY); + return; + } + + snprintf(buffer, + MAX_LINE_SIZE, + "gcc -c -O3 -fpic -Wno-deprecated-declarations -o %s %s " + "-I %s/lib/pipeline " + "-I %s/lib/eal/include " + "-I %s/lib/eal/x86/include " + "-I %s/lib/eal/include/generic " + "-I %s/lib/meter " + "-I %s/lib/port " + "-I %s/lib/table " + "-I %s/lib/pipeline " + "-I %s/config " + "-I %s/build " + "-I %s/lib/eal/linux/include " + ">%s 2>&1 " + "&& " + "gcc -shared %s -o %s " + ">>%s 2>&1", + obj_file, + code_file, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + install_dir, + log_file, + obj_file, + lib_file, + log_file); + + status = system(buffer); + if (status) { + snprintf(out, + out_size, + "Library build failed, see file \"%s\" for details.\n", + log_file); + goto free; + } + +free: + free(obj_file); + free(log_file); + free(buffer); +} + static const char cmd_pipeline_build_help[] = "pipeline build \n"; @@ -1080,10 +1209,6 @@ table_entry_free(struct rte_swx_table_entry *entry) free(entry); } -#ifndef MAX_LINE_SIZE -#define MAX_LINE_SIZE 2048 -#endif - static int pipeline_table_entries_add(struct rte_swx_ctl_pipeline *p, const char *table_name, @@ -3010,6 +3135,7 @@ cmd_help(char **tokens, "\tpipeline port in\n" "\tpipeline port out\n" "\tpipeline codegen\n" + "\tpipeline libbuild\n" "\tpipeline build\n" "\tpipeline table add\n" "\tpipeline table delete\n" @@ -3085,6 +3211,12 @@ cmd_help(char **tokens, return; } + if ((strcmp(tokens[0], "pipeline") == 0) && + (n_tokens == 2) && (strcmp(tokens[1], "libbuild") == 0)) { + snprintf(out, out_size, "\n%s\n", cmd_pipeline_libbuild_help); + return; + } + if ((strcmp(tokens[0], "pipeline") == 0) && (n_tokens == 2) && (strcmp(tokens[1], "build") == 0)) { snprintf(out, out_size, "\n%s\n", cmd_pipeline_build_help); @@ -3370,6 +3502,13 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } + if ((n_tokens >= 3) && + (strcmp(tokens[1], "libbuild") == 0)) { + cmd_pipeline_libbuild(tokens, n_tokens, out, out_size, + obj); + return; + } + if ((n_tokens >= 3) && (strcmp(tokens[2], "build") == 0)) { cmd_pipeline_build(tokens, n_tokens, out, out_size, From patchwork Mon Jul 18 13:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114025 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 58C68A0032; Mon, 18 Jul 2022 15:08:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E4DD42B9F; Mon, 18 Jul 2022 15:07:29 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 8FB5442B84 for ; Mon, 18 Jul 2022 15:07:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658149644; x=1689685644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u7NdvjPuo61F4LV9ks3oyHJs1dXZkfAokU0pLkZq/S4=; b=EQ8SWUQOsQWX2tNCBTGxSp/uep8t+21SGVU5WYzDr9r8StaL3T4y9qxp 8R3ACidXywgX3eJLFQuvpfSQF92S1EmqJAWA4hAna6DZHIfFVhT3yXI5f MeBvucRIs0IVtNiCnyMxjPJ8Ctc3AvbZSjOFnTmYnljOrwafRmXe7x8b6 PNUil7tLnvFLnJA8rQZ1tnwS36qMZ1U64rH4Yp7ZZxcDpa5ZdIU3diuHJ iVunrFKIjYf+crlRiKLreJyiQ1iCVVT8XSXMAoFZBA0VkNnjm884UUax9 HQ/tskDDkjdMikVFd3rMskeraOUTwQv7y/bqoIntAV+wYgafXZpg74poW w==; X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="265996450" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="265996450" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:07:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="739459766" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga001.fm.intel.com with ESMTP; 18 Jul 2022 06:07:22 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH 9/9] examples/pipeline: call CLI commands for code generation and build Date: Mon, 18 Jul 2022 13:07:13 +0000 Message-Id: <20220718130713.339003-9-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update the example CLI scripts with the commands for code generation and shared object library build. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/examples/fib.cli | 8 +++++++- examples/pipeline/examples/hash_func.cli | 8 +++++++- examples/pipeline/examples/l2fwd.cli | 8 +++++++- examples/pipeline/examples/l2fwd_macswp.cli | 8 +++++++- examples/pipeline/examples/l2fwd_macswp_pcap.cli | 8 +++++++- examples/pipeline/examples/l2fwd_pcap.cli | 8 +++++++- examples/pipeline/examples/learner.cli | 8 +++++++- examples/pipeline/examples/meter.cli | 8 +++++++- examples/pipeline/examples/mirroring.cli | 8 +++++++- examples/pipeline/examples/recirculation.cli | 8 +++++++- examples/pipeline/examples/registers.cli | 8 +++++++- examples/pipeline/examples/selector.cli | 8 +++++++- examples/pipeline/examples/varbit.cli | 8 +++++++- examples/pipeline/examples/vxlan.cli | 8 +++++++- examples/pipeline/examples/vxlan_pcap.cli | 8 +++++++- 15 files changed, 105 insertions(+), 15 deletions(-) diff --git a/examples/pipeline/examples/fib.cli b/examples/pipeline/examples/fib.cli index 93ab2b08f8..8b55175bf3 100644 --- a/examples/pipeline/examples/fib.cli +++ b/examples/pipeline/examples/fib.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/fib.spec /tmp/fib.c +pipeline libbuild /tmp/fib.c /tmp/fib.so + ; ; Customize the LINK parameters to match your setup. ; @@ -26,7 +32,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/fib.spec +pipeline PIPELINE0 build /tmp/fib.so ; ; Initial set of table entries. diff --git a/examples/pipeline/examples/hash_func.cli b/examples/pipeline/examples/hash_func.cli index d65cd62d17..f7bb28b28b 100644 --- a/examples/pipeline/examples/hash_func.cli +++ b/examples/pipeline/examples/hash_func.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/hash_func.spec /tmp/hash_func.c +pipeline libbuild /tmp/hash_func.c /tmp/hash_func.so + ; ; Customize the LINK parameters to match your setup. ; @@ -26,7 +32,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/hash_func.spec +pipeline PIPELINE0 build /tmp/hash_func.so ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/l2fwd.cli b/examples/pipeline/examples/l2fwd.cli index d89caf2d0a..a71727309b 100644 --- a/examples/pipeline/examples/l2fwd.cli +++ b/examples/pipeline/examples/l2fwd.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/l2fwd.spec /tmp/l2fwd.c +pipeline libbuild /tmp/l2fwd.c /tmp/l2fwd.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -20,6 +26,6 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd.spec +pipeline PIPELINE0 build /tmp/l2fwd.so thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/l2fwd_macswp.cli b/examples/pipeline/examples/l2fwd_macswp.cli index 0f2a89ac5b..d8f5f9f735 100644 --- a/examples/pipeline/examples/l2fwd_macswp.cli +++ b/examples/pipeline/examples/l2fwd_macswp.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/l2fwd_macswp.spec /tmp/l2fwd_macswp.c +pipeline libbuild /tmp/l2fwd_macswp.c /tmp/l2fwd_macswp.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -20,6 +26,6 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd_macswp.spec +pipeline PIPELINE0 build /tmp/l2fwd_macswp.so thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/l2fwd_macswp_pcap.cli b/examples/pipeline/examples/l2fwd_macswp_pcap.cli index e9656fe3c2..bd077876ff 100644 --- a/examples/pipeline/examples/l2fwd_macswp_pcap.cli +++ b/examples/pipeline/examples/l2fwd_macswp_pcap.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/l2fwd_macswp.spec /tmp/l2fwd_macswp.c +pipeline libbuild /tmp/l2fwd_macswp.c /tmp/l2fwd_macswp.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 pipeline PIPELINE0 create 0 @@ -15,6 +21,6 @@ pipeline PIPELINE0 port out 1 sink none pipeline PIPELINE0 port out 2 sink none pipeline PIPELINE0 port out 3 sink none -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd_macswp.spec +pipeline PIPELINE0 build /tmp/l2fwd_macswp.so thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/l2fwd_pcap.cli b/examples/pipeline/examples/l2fwd_pcap.cli index 23fcb199f1..2e56a116af 100644 --- a/examples/pipeline/examples/l2fwd_pcap.cli +++ b/examples/pipeline/examples/l2fwd_pcap.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/l2fwd.spec /tmp/l2fwd.c +pipeline libbuild /tmp/l2fwd.c /tmp/l2fwd.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 pipeline PIPELINE0 create 0 @@ -15,6 +21,6 @@ pipeline PIPELINE0 port out 1 sink none pipeline PIPELINE0 port out 2 sink none pipeline PIPELINE0 port out 3 sink none -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd.spec +pipeline PIPELINE0 build /tmp/l2fwd.so thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/learner.cli b/examples/pipeline/examples/learner.cli index 688ce34f34..10eb2af417 100644 --- a/examples/pipeline/examples/learner.cli +++ b/examples/pipeline/examples/learner.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/learner.spec /tmp/learner.c +pipeline libbuild /tmp/learner.c /tmp/learner.so + ; ; Customize the LINK parameters to match your setup. ; @@ -26,7 +32,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/learner.spec +pipeline PIPELINE0 build /tmp/learner.so ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/meter.cli b/examples/pipeline/examples/meter.cli index b29ed24022..9c22014f46 100644 --- a/examples/pipeline/examples/meter.cli +++ b/examples/pipeline/examples/meter.cli @@ -4,6 +4,12 @@ ; Example command line: ; ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/meter.cli +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/meter.spec /tmp/meter.c +pipeline libbuild /tmp/meter.c /tmp/meter.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -23,7 +29,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/meter.spec +pipeline PIPELINE0 build /tmp/meter.so pipeline PIPELINE0 meter profile platinum add cir 46000000 pir 138000000 cbs 1000000 pbs 1000000 pipeline PIPELINE0 meter meters from 0 to 15 set profile platinum diff --git a/examples/pipeline/examples/mirroring.cli b/examples/pipeline/examples/mirroring.cli index 46d57db4ec..9614f64d38 100644 --- a/examples/pipeline/examples/mirroring.cli +++ b/examples/pipeline/examples/mirroring.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/mirroring.spec /tmp/mirroring.c +pipeline libbuild /tmp/mirroring.c /tmp/mirroring.so + ; ; Customize the LINK parameters to match your setup. ; @@ -27,7 +33,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/mirroring.spec +pipeline PIPELINE0 build /tmp/mirroring.so ; ; Packet mirroring sessions. diff --git a/examples/pipeline/examples/recirculation.cli b/examples/pipeline/examples/recirculation.cli index f855c5c327..bd114e91cd 100644 --- a/examples/pipeline/examples/recirculation.cli +++ b/examples/pipeline/examples/recirculation.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/recirculation.spec /tmp/recirculation.c +pipeline libbuild /tmp/recirculation.c /tmp/recirculation.so + ; ; Customize the LINK parameters to match your setup. ; @@ -26,7 +32,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/recirculation.spec +pipeline PIPELINE0 build /tmp/recirculation.so ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/registers.cli b/examples/pipeline/examples/registers.cli index 8d026294cb..3d9eeb0d5c 100644 --- a/examples/pipeline/examples/registers.cli +++ b/examples/pipeline/examples/registers.cli @@ -4,6 +4,12 @@ ; Example command line: ; ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/registers.cli +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/registers.spec /tmp/registers.c +pipeline libbuild /tmp/registers.c /tmp/registers.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -23,6 +29,6 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/registers.spec +pipeline PIPELINE0 build /tmp/registers.so thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/selector.cli b/examples/pipeline/examples/selector.cli index 123782c57b..6c7d032b10 100644 --- a/examples/pipeline/examples/selector.cli +++ b/examples/pipeline/examples/selector.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/selector.spec /tmp/selector.c +pipeline libbuild /tmp/selector.c /tmp/selector.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -20,7 +26,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/selector.spec +pipeline PIPELINE0 build /tmp/selector.so pipeline PIPELINE0 selector s group add pipeline PIPELINE0 selector s group member add ./examples/pipeline/examples/selector.txt diff --git a/examples/pipeline/examples/varbit.cli b/examples/pipeline/examples/varbit.cli index 9caeb9ca26..545cde262e 100644 --- a/examples/pipeline/examples/varbit.cli +++ b/examples/pipeline/examples/varbit.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/varbit.spec /tmp/varbit.c +pipeline libbuild /tmp/varbit.c /tmp/varbit.so + ; ; Customize the LINK parameters to match your setup. ; @@ -26,7 +32,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/varbit.spec +pipeline PIPELINE0 build /tmp/varbit.so ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/vxlan.cli b/examples/pipeline/examples/vxlan.cli index 444f3f7bd8..321a28ba44 100644 --- a/examples/pipeline/examples/vxlan.cli +++ b/examples/pipeline/examples/vxlan.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/vxlan.spec /tmp/vxlan.c +pipeline libbuild /tmp/vxlan.c /tmp/vxlan.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 link LINK0 dev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on @@ -20,7 +26,7 @@ pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32 -pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec +pipeline PIPELINE0 build /tmp/vxlan.so pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt pipeline PIPELINE0 commit diff --git a/examples/pipeline/examples/vxlan_pcap.cli b/examples/pipeline/examples/vxlan_pcap.cli index 83fca8d0d9..596169f933 100644 --- a/examples/pipeline/examples/vxlan_pcap.cli +++ b/examples/pipeline/examples/vxlan_pcap.cli @@ -1,6 +1,12 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +; +; Pipeline code generation & shared object library build +; +pipeline codegen ./examples/pipeline/examples/vxlan.spec /tmp/vxlan.c +pipeline libbuild /tmp/vxlan.c /tmp/vxlan.so + mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 pipeline PIPELINE0 create 0 @@ -15,7 +21,7 @@ pipeline PIPELINE0 port out 1 sink none pipeline PIPELINE0 port out 2 sink none pipeline PIPELINE0 port out 3 sink none -pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec +pipeline PIPELINE0 build /tmp/vxlan.so pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt pipeline PIPELINE0 commit