From patchwork Wed Jul 27 23:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114313 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 3E272A00C4; Thu, 28 Jul 2022 01:01:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA8E6427ED; Thu, 28 Jul 2022 01:01:36 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id ED1D640E25 for ; Thu, 28 Jul 2022 01:01:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962895; x=1690498895; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eqJK7rM0AIyqLHe6hbcrRFn7PUbXHjOuexm3zcWcmBw=; b=fUHuMi4D+H5SQ3sOp5aPvkGehqilII5YTvG3a/p1esmhboDSf4P7BQTG XxXbfyqdrSUpqN/5rw50+Ud2+CQeMGQXNhVl+gS/P+OLvqyyciWuK5CNH WaO8fsdpLMQe0vqqQP6+T192aHZ/rekF1j47maXgMm1cdQcDb/DWbOHIq mmP1hDOg+mELoPIVakFvH+ijWcO6VJT2SwokBqtFWDiZc2pnLbs4wusuy fifNx8B5HmS/e4rKoJBp6wz/SsFPV2rFKp5/wTQWPG7ieLl/HAPwVHILN 7eb7a3A8Mg/NUeCLV11mLVtpGpYfi3PtgXabdM+BdIGgk8kQ5QpLnHx0d g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150867" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150867" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444279" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:32 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 01/17] pipeline: add pipeline name Date: Wed, 27 Jul 2022 23:01:16 +0000 Message-Id: <20220727230132.601114-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727225431.600913-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-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 an unique name to every pipeline. This enables the library to maintain a list of the existing pipeline objects, which can be queried by the application. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/obj.c | 2 +- lib/pipeline/rte_swx_ctl.c | 99 +++++++++++++++++++++ lib/pipeline/rte_swx_ctl.h | 15 ++++ lib/pipeline/rte_swx_pipeline.c | 107 ++++++++++++++++++++++- lib/pipeline/rte_swx_pipeline.h | 18 +++- lib/pipeline/rte_swx_pipeline_internal.h | 2 + lib/pipeline/version.map | 4 + 7 files changed, 244 insertions(+), 3 deletions(-) diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index b79f044ac7..967342c580 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -533,7 +533,7 @@ pipeline_create(struct obj *obj, const char *name, int numa_node) return NULL; /* Resource create */ - status = rte_swx_pipeline_config(&p, numa_node); + status = rte_swx_pipeline_config(&p, name, numa_node); if (status) goto error; diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c index 710e89a46a..1b776fc543 100644 --- a/lib/pipeline/rte_swx_ctl.c +++ b/lib/pipeline/rte_swx_ctl.c @@ -9,6 +9,8 @@ #include #include +#include +#include #include @@ -1157,12 +1159,103 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl) return status; } +/* Global list of pipeline instances. */ +TAILQ_HEAD(rte_swx_ctl_pipeline_list, rte_tailq_entry); + +static struct rte_tailq_elem rte_swx_ctl_pipeline_tailq = { + .name = "RTE_SWX_CTL_PIPELINE", +}; + +EAL_REGISTER_TAILQ(rte_swx_ctl_pipeline_tailq) + +struct rte_swx_ctl_pipeline * +rte_swx_ctl_pipeline_find(const char *name) +{ + struct rte_swx_ctl_pipeline_list *ctl_list; + struct rte_tailq_entry *te = NULL; + + if (!name || !name[0] || (strnlen(name, RTE_SWX_CTL_NAME_SIZE) >= RTE_SWX_CTL_NAME_SIZE)) + return NULL; + + ctl_list = RTE_TAILQ_CAST(rte_swx_ctl_pipeline_tailq.head, rte_swx_ctl_pipeline_list); + + rte_mcfg_tailq_read_lock(); + + TAILQ_FOREACH(te, ctl_list, next) { + struct rte_swx_ctl_pipeline *ctl = (struct rte_swx_ctl_pipeline *)te->data; + + if (!strncmp(name, ctl->info.name, sizeof(ctl->info.name))) { + rte_mcfg_tailq_read_unlock(); + return ctl; + } + } + + rte_mcfg_tailq_read_unlock(); + return NULL; +} + +static int +ctl_register(struct rte_swx_ctl_pipeline *ctl) +{ + struct rte_swx_ctl_pipeline_list *ctl_list; + struct rte_tailq_entry *te = NULL; + + ctl_list = RTE_TAILQ_CAST(rte_swx_ctl_pipeline_tailq.head, rte_swx_ctl_pipeline_list); + + rte_mcfg_tailq_write_lock(); + + TAILQ_FOREACH(te, ctl_list, next) { + struct rte_swx_ctl_pipeline *ctl_crt = (struct rte_swx_ctl_pipeline *)te->data; + + if (!strncmp(ctl->info.name, ctl_crt->info.name, sizeof(ctl->info.name))) { + rte_mcfg_tailq_write_unlock(); + return -EEXIST; + } + } + + te = calloc(1, sizeof(struct rte_tailq_entry)); + if (!te) { + rte_mcfg_tailq_write_unlock(); + return -ENOMEM; + } + + te->data = (void *)ctl; + TAILQ_INSERT_TAIL(ctl_list, te, next); + rte_mcfg_tailq_write_unlock(); + return 0; +} + +static void +ctl_unregister(struct rte_swx_ctl_pipeline *ctl) +{ + struct rte_swx_ctl_pipeline_list *ctl_list; + struct rte_tailq_entry *te = NULL; + + ctl_list = RTE_TAILQ_CAST(rte_swx_ctl_pipeline_tailq.head, rte_swx_ctl_pipeline_list); + + rte_mcfg_tailq_write_lock(); + + TAILQ_FOREACH(te, ctl_list, next) { + if (te->data == (void *)ctl) { + TAILQ_REMOVE(ctl_list, te, next); + rte_mcfg_tailq_write_unlock(); + free(te); + return; + } + } + + rte_mcfg_tailq_write_unlock(); +} + void rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl) { if (!ctl) return; + if (ctl->info.name[0]) + ctl_unregister(ctl); + action_free(ctl); table_state_free(ctl); @@ -1441,6 +1534,12 @@ rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p) if (status) goto error; + if (ctl->info.name[0]) { + status = ctl_register(ctl); + if (status) + goto error; + } + return ctl; error: diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h index d771389d26..63ee479e47 100644 --- a/lib/pipeline/rte_swx_ctl.h +++ b/lib/pipeline/rte_swx_ctl.h @@ -35,6 +35,9 @@ struct rte_swx_pipeline; /** Pipeline info. */ struct rte_swx_ctl_pipeline_info { + /** Pipeline name. */ + char name[RTE_SWX_CTL_NAME_SIZE]; + /** Number of input ports. */ uint32_t n_ports_in; @@ -812,6 +815,18 @@ rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p, /** Pipeline control opaque data structure. */ struct rte_swx_ctl_pipeline; +/** + * Pipeline control find + * + * @param[in] name + * Pipeline name. + * @return + * Valid pipeline control handle if found or NULL otherwise. + */ +__rte_experimental +struct rte_swx_ctl_pipeline * +rte_swx_ctl_pipeline_find(const char *name); + /** * Pipeline control create * diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 3e1c6e9edb..c8ccded4f8 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include @@ -9578,6 +9580,95 @@ metarray_free(struct rte_swx_pipeline *p) /* * Pipeline. */ + +/* Global list of pipeline instances. */ +TAILQ_HEAD(rte_swx_pipeline_list, rte_tailq_entry); + +static struct rte_tailq_elem rte_swx_pipeline_tailq = { + .name = "RTE_SWX_PIPELINE", +}; + +EAL_REGISTER_TAILQ(rte_swx_pipeline_tailq) + +struct rte_swx_pipeline * +rte_swx_pipeline_find(const char *name) +{ + struct rte_swx_pipeline_list *pipeline_list; + struct rte_tailq_entry *te = NULL; + + if (!name || !name[0] || (strnlen(name, RTE_SWX_NAME_SIZE) >= RTE_SWX_NAME_SIZE)) + return NULL; + + pipeline_list = RTE_TAILQ_CAST(rte_swx_pipeline_tailq.head, rte_swx_pipeline_list); + + rte_mcfg_tailq_read_lock(); + + TAILQ_FOREACH(te, pipeline_list, next) { + struct rte_swx_pipeline *p = (struct rte_swx_pipeline *)te->data; + + if (!strncmp(name, p->name, sizeof(p->name))) { + rte_mcfg_tailq_read_unlock(); + return p; + } + } + + rte_mcfg_tailq_read_unlock(); + return NULL; +} + +static int +pipeline_register(struct rte_swx_pipeline *p) +{ + struct rte_swx_pipeline_list *pipeline_list; + struct rte_tailq_entry *te = NULL; + + pipeline_list = RTE_TAILQ_CAST(rte_swx_pipeline_tailq.head, rte_swx_pipeline_list); + + rte_mcfg_tailq_write_lock(); + + TAILQ_FOREACH(te, pipeline_list, next) { + struct rte_swx_pipeline *pipeline = (struct rte_swx_pipeline *)te->data; + + if (!strncmp(p->name, pipeline->name, sizeof(p->name))) { + rte_mcfg_tailq_write_unlock(); + return -EEXIST; + } + } + + te = calloc(1, sizeof(struct rte_tailq_entry)); + if (!te) { + rte_mcfg_tailq_write_unlock(); + return -ENOMEM; + } + + te->data = (void *)p; + TAILQ_INSERT_TAIL(pipeline_list, te, next); + rte_mcfg_tailq_write_unlock(); + return 0; +} + +static void +pipeline_unregister(struct rte_swx_pipeline *p) +{ + struct rte_swx_pipeline_list *pipeline_list; + struct rte_tailq_entry *te = NULL; + + pipeline_list = RTE_TAILQ_CAST(rte_swx_pipeline_tailq.head, rte_swx_pipeline_list); + + rte_mcfg_tailq_write_lock(); + + TAILQ_FOREACH(te, pipeline_list, next) { + if (te->data == (void *)p) { + TAILQ_REMOVE(pipeline_list, te, next); + rte_mcfg_tailq_write_unlock(); + free(te); + return; + } + } + + rte_mcfg_tailq_write_unlock(); +} + void rte_swx_pipeline_free(struct rte_swx_pipeline *p) { @@ -9586,6 +9677,9 @@ rte_swx_pipeline_free(struct rte_swx_pipeline *p) if (!p) return; + if (p->name[0]) + pipeline_unregister(p); + lib = p->lib; free(p->instruction_data); @@ -9720,13 +9814,14 @@ hash_funcs_register(struct rte_swx_pipeline *p) } int -rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) +rte_swx_pipeline_config(struct rte_swx_pipeline **p, const char *name, int numa_node) { struct rte_swx_pipeline *pipeline = NULL; int status = 0; /* Check input parameters. */ CHECK(p, EINVAL); + CHECK(!name || (strnlen(name, RTE_SWX_NAME_SIZE) < RTE_SWX_NAME_SIZE), EINVAL); /* Memory allocation. */ pipeline = calloc(1, sizeof(struct rte_swx_pipeline)); @@ -9736,6 +9831,9 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) } /* Initialization. */ + if (name) + strcpy(pipeline->name, name); + TAILQ_INIT(&pipeline->struct_types); TAILQ_INIT(&pipeline->port_in_types); TAILQ_INIT(&pipeline->ports_in); @@ -9776,6 +9874,12 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) if (status) goto error; + if (pipeline->name[0]) { + status = pipeline_register(pipeline); + if (status) + goto error; + } + *p = pipeline; return 0; @@ -9966,6 +10070,7 @@ rte_swx_ctl_pipeline_info_get(struct rte_swx_pipeline *p, TAILQ_FOREACH(table, &p->tables, node) n_tables++; + strcpy(pipeline->name, p->name); pipeline->n_ports_in = p->n_ports_in; pipeline->n_ports_out = p->n_ports_out; pipeline->n_mirroring_slots = p->n_mirroring_slots; diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index c41ca5cb15..ef50a0fa70 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -44,22 +44,38 @@ extern "C" { /** Pipeline opaque data structure. */ struct rte_swx_pipeline; +/** + * Pipeline find + * + * @param[in] name + * Pipeline name. + * @return + * Valid pipeline handle if found or NULL otherwise. + */ +__rte_experimental +struct rte_swx_pipeline * +rte_swx_pipeline_find(const char *name); + /** * Pipeline configure * * @param[out] p * Pipeline handle. Must point to valid memory. Contains valid pipeline handle * when the function returns successfully. + * @param[in] name + * Pipeline unique name. * @param[in] numa_node * Non-Uniform Memory Access (NUMA) node. * @return * 0 on success or the following error codes otherwise: * -EINVAL: Invalid argument; - * -ENOMEM: Not enough space/cannot allocate memory. + * -ENOMEM: Not enough space/cannot allocate memory; + * -EEXIST: Pipeline with this name already exists. */ __rte_experimental int rte_swx_pipeline_config(struct rte_swx_pipeline **p, + const char *name, int numa_node); /* diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h index a35635efb7..588cad62b5 100644 --- a/lib/pipeline/rte_swx_pipeline_internal.h +++ b/lib/pipeline/rte_swx_pipeline_internal.h @@ -1459,6 +1459,8 @@ instr_operand_nbo(struct thread *t, const struct instr_operand *x) #endif struct rte_swx_pipeline { + char name[RTE_SWX_NAME_SIZE]; + struct struct_type_tailq struct_types; struct port_in_type_tailq port_in_types; struct port_in_tailq ports_in; diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map index 8312307a7a..50029aadcf 100644 --- a/lib/pipeline/version.map +++ b/lib/pipeline/version.map @@ -145,4 +145,8 @@ 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_ctl_pipeline_find; + rte_swx_pipeline_find; }; From patchwork Wed Jul 27 23:01:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114314 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 5F374A00C4; Thu, 28 Jul 2022 01:01:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE89C42B71; Thu, 28 Jul 2022 01:01:38 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id B770D40E25 for ; Thu, 28 Jul 2022 01:01:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962896; x=1690498896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QGOlaI25Cq/W2w3fmxfgarFtx5//9Ylju/pTtyV5fZc=; b=lwsJAqWYuLvQmI5F9pQ9sCIgHJ6qxNZfaf4UCYFfvMhAKll4WZ7U98Kr Nz3sIavBwZc9b5vomn2WDqo+LmA4z1BHDIop6d5v2x5JTF5jTr2jEDD+i FFmKDMNJ2SperrZNPis5gxFOMMRGwS45tdvsENuRdyV0gIai+wfMaTmpL Zf4OubKAsBxYQNMz93TjrazvLmFAk7jbn43LLgXkFi+RQl1kV/WKrgyO2 ReNcR9Mwu0zAO8iVqoQNeRBFnWXu2qvyht46SyPHcjFprSkCFTvP0QQSw EEAiLQbvXd560F37GN5xGHhUACJ2S4Eie2BbArptOYGG0ayUgQBs2WpU9 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150871" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150871" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444284" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:34 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 02/17] pipeline: move specification data structures to internal header Date: Wed, 27 Jul 2022 23:01:17 +0000 Message-Id: <20220727230132.601114-2-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 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 Wed Jul 27 23:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114315 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 00689A00C4; Thu, 28 Jul 2022 01:01:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 979F142826; Thu, 28 Jul 2022 01:01:39 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 8FDA040E25 for ; Thu, 28 Jul 2022 01:01:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962896; x=1690498896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UzzpIhJ2abbRozU27BFdEHiHwKlZzXx+954EfyzY78c=; b=eutnOykAdDtqfMc/xLFhHlZ89WvYuN9MXAyA/KGWDWjOLhlfTrd9o6pP tlKHca/conBhdXfzxnyDoM7OUpa7qP/WjPSwO2OGVKziTU/loggbd/23S URPFJTSNwfI7bhieleL8pO8y62nkFxulJ0oH4ku3jDjYJXzXFI8/kQD6/ p7q3pAOfDvktIc3vp0Qvaz6FBZDGbZG5toiUqr+w/Li6q4Dj3JsAC/yPL J12v8RgZ0saFrmPG9WS4IXz8P51kJ9/x9D772zCpOVE6lG0Y3eK9loGS/ ezmV03EW/tQQ3wgNagE7Mejv8D6ARthXaVbAD8ULUhZy5BSd3tvXFywXa w==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150880" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150880" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444291" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:35 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 03/17] pipeline: add pipeline specification data structure Date: Wed, 27 Jul 2022 23:01:18 +0000 Message-Id: <20220727230132.601114-3-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 Wed Jul 27 23:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114316 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 48064A00C4; Thu, 28 Jul 2022 01:01:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65EFB42B82; Thu, 28 Jul 2022 01:01:40 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 78FEF42826 for ; Thu, 28 Jul 2022 01:01:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962897; x=1690498897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/Tc0YNchNec0Ple4MywKk1sdw752M8EjNw570gyqv2c=; b=Gx+tKQYCNGR66s9kMRNQ58IX3Z1RmKLyjAEIikP3+Dmk7tWAxgZIJa38 cRWemLh9yrCMN2e1rW7emzZ2DzP/h8W/+20Enky+fpYkGnj5slycGWxNt nXXqY93pHTdvUDFGPdSYA8jCHaoYWp2I9KSmyTkTi6e1BpFxt4kpmrN+4 DstmOIKOOJi/5jGZM+57CaRKbEg7iqzZ27h6KyCdQMxB+Gac0Mdsj2kCr JDdmawxQKx/KdJK3XTwt0OMbrPtb12UnMSyS7f7zeA+8y1ZAfDosr+mrX PbfUwvMCcVDsgBQcPIblWQZdsH26Kfk1oIrqV2EH1yZCSP6JzjEXwHsfd Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150888" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150888" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444301" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:35 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 04/17] pipeline: rework the specification file-based pipeline build Date: Wed, 27 Jul 2022 23:01:19 +0000 Message-Id: <20220727230132.601114-4-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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..62929a9da6 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 Wed Jul 27 23:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114317 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 CAC36A00C4; Thu, 28 Jul 2022 01:02:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8101142B95; Thu, 28 Jul 2022 01:01:42 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 906C742826 for ; Thu, 28 Jul 2022 01:01:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962898; x=1690498898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kV8l83wbMRr+LMoXR2nwmAq9SLVd4xV9uLu3kZf6vKM=; b=Cmkn142lNDspHqs+WH0RZpSPYay1XKc2v/kqZK3SWs7Xr47r3HtBbcFQ YcMZQEVHdBirqIBEpK+oDtSVvEw7hYHrn9XecbDmSJbyCwJA31BeBesmG WXfwocuXTmgYKlP8HzCwIGjXMravJsLKof2AGUZz4hRs41m94YNzs/DJZ vNbqX2cVW6d7xiswTOFc1A/oqEOJHGtLlca09+y7ZZjZtT7LojcETAYsn kiJAGGcB4/IX8hEIG1NplplzOKkagwsIHacuszNJc8i3SBZapKxRWiKvp cZBkPREtcGKbFXQAFxvKICPoRLgNRcfn8o6+o0CUD6qJ42LMiITMjvsir A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150894" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150894" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444308" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:37 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 05/17] pipeline: generate the code for pipeline specification structure Date: Wed, 27 Jul 2022 23:01:20 +0000 Message-Id: <20220727230132.601114-5-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 | 622 +++++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline_spec.h | 5 + 2 files changed, 627 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index 62929a9da6..bf21fe17ba 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,627 @@ 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 Wed Jul 27 23:01:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114318 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 20498A00C4; Thu, 28 Jul 2022 01:02:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6240442BA8; Thu, 28 Jul 2022 01:01:43 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E558C42B7A for ; Thu, 28 Jul 2022 01:01:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962900; x=1690498900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mypTbadyUjL6rCZqn0FzsdW+MU0EF0QJY1woIO74AGw=; b=P/acu80ay7xAtB0wE6yVSOTRDd0Ld1h5uByg7DwXXRfw/eqcjt/+Cz1M lEuaxApgZJIP/fT7BnY3Gb/Xjwuk023TwFClLs7q1E3UxnTFloSeUlCKk HyMC4Brd7IUYzbx2YjyWvISnXosknQ6/94yGO6vfJMnVeOevkApAbp6U3 Y2m3eER34v1pmGNjrOfcXpwxmidCGscCisWQzKINFaARTrqmSSHtEQ3yB QP2cHO5FAhGLI0NwPzZmi3lD3JEuZT1sYBmfDW2XO7qxSejhIbvjiuk1T ikBzSe6716ZNQTcsICkN9vSL5KPWCE0kGeXNWRPzxgICfdyPezHR7JGRR w==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150905" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150905" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444319" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:38 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 06/17] pipeline: add support for pipeline I/O specification Date: Wed, 27 Jul 2022 23:01:21 +0000 Message-Id: <20220727230132.601114-6-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 and API for the pipeline I/O ports and related pipeline configuration such as packet mirroring. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- lib/pipeline/rte_swx_pipeline_spec.c | 852 +++++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline_spec.h | 58 ++ 2 files changed, 910 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index bf21fe17ba..f34803793d 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.c +++ b/lib/pipeline/rte_swx_pipeline_spec.c @@ -9,6 +9,12 @@ #include #include +#include + +#include +#include +#include +#include #include "rte_swx_pipeline_spec.h" @@ -3566,3 +3572,849 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, pipeline_spec_free(s); return status; } + +static void +port_in_params_free(void *params, const char *port_type) +{ + uintptr_t dev_name; + + if (!params || !port_type) + return; + + if (!strcmp(port_type, "ethdev")) { + struct rte_swx_port_ethdev_reader_params *p = params; + + dev_name = (uintptr_t)p->dev_name; + } else if (!strcmp(port_type, "ring")) { + struct rte_swx_port_ring_reader_params *p = params; + + dev_name = (uintptr_t)p->name; + } else if (!strcmp(port_type, "source")) { + struct rte_swx_port_source_params *p = params; + + dev_name = (uintptr_t)p->file_name; + } else + dev_name = (uintptr_t)NULL; + + free((void *)dev_name); + free(params); +} + +static void +port_out_params_free(void *params, const char *port_type) +{ + uintptr_t dev_name; + + if (!params || !port_type) + return; + + if (!strcmp(port_type, "ethdev")) { + struct rte_swx_port_ethdev_writer_params *p = params; + + dev_name = (uintptr_t)p->dev_name; + } else if (!strcmp(port_type, "ring")) { + struct rte_swx_port_ring_writer_params *p = params; + + dev_name = (uintptr_t)p->name; + } else if (!strcmp(port_type, "sink")) { + struct rte_swx_port_sink_params *p = params; + + dev_name = (uintptr_t)p->file_name; + } else + dev_name = (uintptr_t)NULL; + + free((void *)dev_name); + free(params); +} + +void +pipeline_iospec_free(struct pipeline_iospec *s) +{ + uint32_t i; + + if (!s) + return; + + /* Input ports. */ + for (i = 0; i < s->n_ports_in; i++) { + uintptr_t name = (uintptr_t)s->port_in_type[i]; + + port_in_params_free(s->port_in_params[i], s->port_in_type[i]); + free((void *)name); + } + + free(s->port_in_type); + free(s->port_in_params); + + /* Output ports. */ + for (i = 0; i < s->n_ports_out; i++) { + uintptr_t name = (uintptr_t)s->port_out_type[i]; + + port_out_params_free(s->port_out_params[i], s->port_out_type[i]); + free((void *)name); + } + + free(s->port_out_type); + free(s->port_out_params); + + free(s); +} + +static int +mirroring_parse(struct rte_swx_pipeline_mirroring_params *p, + char **tokens, + uint32_t n_tokens, + const char **err_msg) +{ + char *token; + + if ((n_tokens != 4) || strcmp(tokens[0], "slots") || strcmp(tokens[2], "sessions")) { + if (err_msg) + *err_msg = "Invalid statement."; + return -EINVAL; + } + + /* . */ + token = tokens[1]; + p->n_slots = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return -EINVAL; + } + + /* . */ + token = tokens[3]; + p->n_sessions = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return -EINVAL; + } + + return 0; +} + +static void * +port_in_ethdev_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_ethdev_reader_params *p = NULL; + char *token, *dev_name = NULL; + uint32_t queue_id, burst_size; + + if ((n_tokens != 5) || strcmp(tokens[1], "rxq") || strcmp(tokens[3], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[2]; + queue_id = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[4]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + dev_name = strdup(tokens[0]); + p = malloc(sizeof(struct rte_swx_port_ethdev_reader_params)); + if (!dev_name || !p) { + free(dev_name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->dev_name = dev_name; + p->queue_id = queue_id; + p->burst_size = burst_size; + + return p; +} + +static void * +port_in_ring_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_ring_reader_params *p = NULL; + char *token, *name = NULL; + uint32_t burst_size; + + if ((n_tokens != 3) || strcmp(tokens[1], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[2]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + name = strdup(tokens[0]); + p = malloc(sizeof(struct rte_swx_port_ring_reader_params)); + if (!name || !p) { + free(name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->name = name; + p->burst_size = burst_size; + + return p; +} + +static void * +port_in_source_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_source_params *p = NULL; + struct rte_mempool *pool = NULL; + char *token, *file_name = NULL; + uint32_t n_loops, n_pkts_max; + + if ((n_tokens != 8) || + strcmp(tokens[0], "mempool") || + strcmp(tokens[2], "file") || + strcmp(tokens[4], "loop") || + strcmp(tokens[6], "packets")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + pool = rte_mempool_lookup(tokens[1]); + if (!pool) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[5]; + n_loops = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[7]; + n_pkts_max = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + file_name = strdup(tokens[3]); + p = malloc(sizeof(struct rte_swx_port_source_params)); + if (!file_name || !p) { + free(file_name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->pool = pool; + p->file_name = file_name; + p->n_loops = n_loops; + p->n_pkts_max = n_pkts_max; + + return p; +} + +static void * +port_in_fd_parse(char **tokens, + uint32_t n_tokens, + const char **err_msg) +{ + struct rte_swx_port_fd_reader_params *p = NULL; + struct rte_mempool *mempool = NULL; + char *token; + uint32_t mtu, burst_size; + int fd; + + if ((n_tokens != 7) || + strcmp(tokens[1], "mtu") || + strcmp(tokens[3], "mempool") || + strcmp(tokens[5], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[0]; + fd = strtol(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[2]; + mtu = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + mempool = rte_mempool_lookup(tokens[4]); + if (!mempool) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[6]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + p = malloc(sizeof(struct rte_swx_port_fd_reader_params)); + if (!p) { + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->fd = fd; + p->mtu = mtu; + p->mempool = mempool; + p->burst_size = burst_size; + + return p; +} + +static void * +port_out_ethdev_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_ethdev_writer_params *p = NULL; + char *token, *dev_name = NULL; + uint32_t queue_id, burst_size; + + if ((n_tokens != 5) || strcmp(tokens[1], "txq") || strcmp(tokens[3], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[2]; + queue_id = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[4]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + dev_name = strdup(tokens[0]); + p = malloc(sizeof(struct rte_swx_port_ethdev_writer_params)); + if (!dev_name || !p) { + free(dev_name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->dev_name = dev_name; + p->queue_id = queue_id; + p->burst_size = burst_size; + + return p; +} + +static void * +port_out_ring_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_ring_writer_params *p = NULL; + char *token, *name = NULL; + uint32_t burst_size; + + if ((n_tokens != 3) || strcmp(tokens[1], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[2]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + name = strdup(tokens[0]); + p = malloc(sizeof(struct rte_swx_port_ring_writer_params)); + if (!name || !p) { + free(name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->name = name; + p->burst_size = burst_size; + + return p; +} + +static void * +port_out_sink_parse(char **tokens, uint32_t n_tokens, const char **err_msg) +{ + struct rte_swx_port_sink_params *p = NULL; + char *file_name = NULL; + int file_name_valid = 0; + + if ((n_tokens != 2) || strcmp(tokens[0], "file")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* Memory allocation. */ + if (strcmp(tokens[1], "none")) { + file_name_valid = 1; + file_name = strdup(tokens[1]); + } + + p = malloc(sizeof(struct rte_swx_port_ring_writer_params)); + if ((file_name_valid && !file_name) || !p) { + free(file_name); + free(p); + + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->file_name = file_name; + + return p; +} + +static void * +port_out_fd_parse(char **tokens, + uint32_t n_tokens, + const char **err_msg) +{ + struct rte_swx_port_fd_writer_params *p = NULL; + char *token; + uint32_t burst_size; + int fd; + + if ((n_tokens != 3) || strcmp(tokens[1], "bsz")) { + if (err_msg) + *err_msg = "Invalid statement."; + return NULL; + } + + /* . */ + token = tokens[0]; + fd = strtol(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* . */ + token = tokens[2]; + burst_size = strtoul(token, &token, 0); + if (token[0]) { + if (err_msg) + *err_msg = "Invalid parameter."; + return NULL; + } + + /* Memory allocation. */ + p = malloc(sizeof(struct rte_swx_port_fd_writer_params)); + if (!p) { + if (err_msg) + *err_msg = "Memory allocation failed."; + return NULL; + } + + /* Initialization. */ + p->fd = fd; + p->burst_size = burst_size; + + return p; +} + +struct pipeline_iospec * +pipeline_iospec_parse(FILE *spec, + uint32_t *err_line, + const char **err_msg) +{ + struct pipeline_iospec *s = NULL; + uint32_t n_lines = 0; + + /* Check the input arguments. */ + if (!spec) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Invalid input argument."; + goto error; + } + + /* Memory allocation. */ + s = calloc(sizeof(struct pipeline_iospec), 1); + if (!s) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Memory allocation failed."; + goto error; + } + + /* Initialize with the default values. */ + s->mirroring_params.n_slots = RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT; + s->mirroring_params.n_sessions = RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT; + + for (n_lines = 1; ; n_lines++) { + char line[MAX_LINE_LENGTH]; + char *tokens[MAX_TOKENS], *ptr = line; + uint32_t n_tokens = 0; + + /* Read next line. */ + if (!fgets(line, sizeof(line), spec)) + break; + + /* Parse the line into tokens. */ + for ( ; ; ) { + char *token; + + /* Get token. */ + token = strtok_r(ptr, " \f\n\r\t\v", &ptr); + if (!token) + break; + + /* Handle comments. */ + if ((token[0] == '#') || + (token[0] == ';') || + ((token[0] == '/') && (token[1] == '/'))) { + break; + } + + /* Handle excessively long lines. */ + if (n_tokens >= RTE_DIM(tokens)) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Too many tokens."; + goto error; + } + + /* Handle excessively long tokens. */ + if (strnlen(token, RTE_SWX_NAME_SIZE) >= + RTE_SWX_NAME_SIZE) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Token too big."; + goto error; + } + + /* Save token. */ + tokens[n_tokens] = token; + n_tokens++; + } + + /* Handle empty lines. */ + if (!n_tokens) + continue; + + /* mirroring. */ + if ((n_tokens >= 1) && !strcmp(tokens[0], "mirroring")) { + int status = 0; + + status = mirroring_parse(&s->mirroring_params, + &tokens[1], + n_tokens - 1, + err_msg); + if (status) { + if (err_line) + *err_line = n_lines; + goto error; + } + + continue; + } + + /* port in. */ + if ((n_tokens >= 4) && !strcmp(tokens[0], "port") && !strcmp(tokens[1], "in")) { + char *token = tokens[2]; + uint32_t *new_id = NULL; + const char **new_type = NULL, *port_type = NULL; + void **new_params = NULL, *p = NULL; + uint32_t port_id; + + /* . */ + port_id = strtoul(token, &token, 0); + if (token[0]) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Invalid port ID."; + goto error; + } + + /* . */ + if (!strcmp(tokens[3], "ethdev")) + p = port_in_ethdev_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "ring")) + p = port_in_ring_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "source")) + p = port_in_source_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "fd")) + p = port_in_fd_parse(&tokens[4], n_tokens - 4, err_msg); + else { + p = NULL; + if (err_msg) + *err_msg = "Invalid port type."; + } + + if (!p) { + if (err_line) + *err_line = n_lines; + goto error; + } + + /* New port. */ + port_type = strdup(tokens[3]); + new_id = realloc(s->port_in_id, + (s->n_ports_in + 1) * sizeof(uint32_t)); + new_type = realloc(s->port_in_type, + (s->n_ports_in + 1) * sizeof(char *)); + new_params = realloc(s->port_in_params, + (s->n_ports_in + 1) * sizeof(void *)); + if (!port_type || !new_id || !new_type || !new_params) { + uintptr_t pt = (uintptr_t)port_type; + + port_in_params_free(p, tokens[3]); + free((void *)pt); + free(new_id); + free(new_type); + free(new_params); + + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Memory allocation failed."; + goto error; + } + + s->port_in_id = new_id; + s->port_in_type = new_type; + s->port_in_params = new_params; + + s->port_in_id[s->n_ports_in] = port_id; + s->port_in_type[s->n_ports_in] = port_type; + s->port_in_params[s->n_ports_in] = p; + s->n_ports_in++; + + continue; + } + + /* port out. */ + if ((n_tokens >= 4) && !strcmp(tokens[0], "port") && !strcmp(tokens[1], "out")) { + char *token = tokens[2]; + uint32_t *new_id = NULL; + const char **new_type = NULL, *port_type = NULL; + void **new_params = NULL, *p = NULL; + uint32_t port_id; + + /* . */ + port_id = strtoul(token, &token, 0); + if (token[0]) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Invalid port ID."; + goto error; + } + + /* . */ + if (!strcmp(tokens[3], "ethdev")) + p = port_out_ethdev_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "ring")) + p = port_out_ring_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "sink")) + p = port_out_sink_parse(&tokens[4], n_tokens - 4, err_msg); + else if (!strcmp(tokens[3], "fd")) + p = port_out_fd_parse(&tokens[4], n_tokens - 4, err_msg); + else { + p = NULL; + if (err_msg) + *err_msg = "Invalid port type."; + } + + if (!p) { + if (err_line) + *err_line = n_lines; + goto error; + } + + /* New port. */ + port_type = strdup(tokens[3]); + new_id = realloc(s->port_out_id, + (s->n_ports_out + 1) * sizeof(uint32_t)); + new_type = realloc(s->port_out_type, + (s->n_ports_out + 1) * sizeof(char *)); + new_params = realloc(s->port_out_params, + (s->n_ports_out + 1) * sizeof(void *)); + if (!port_type || !new_id || !new_type || !new_params) { + uintptr_t pt = (uintptr_t)port_type; + + port_out_params_free(p, tokens[3]); + free((void *)pt); + free(new_id); + free(new_type); + free(new_params); + + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Memory allocation failed."; + goto error; + } + + s->port_out_id = new_id; + s->port_out_type = new_type; + s->port_out_params = new_params; + + s->port_out_id[s->n_ports_out] = port_id; + s->port_out_type[s->n_ports_out] = port_type; + s->port_out_params[s->n_ports_out] = p; + s->n_ports_out++; + + continue; + } + + /* Anything else. */ + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Unknown I/O statement."; + goto error; + } + + return s; + +error: + pipeline_iospec_free(s); + + return NULL; +} + +int +pipeline_iospec_configure(struct rte_swx_pipeline *p, + struct pipeline_iospec *s, + const char **err_msg) +{ + uint32_t i; + int status = 0; + + /* Check input arguments. */ + if (!p || !s) { + if (err_msg) + *err_msg = "Invalid input argument"; + return -EINVAL; + } + + /* Mirroring. */ + status = rte_swx_pipeline_mirroring_config(p, &s->mirroring_params); + if (status) { + if (err_msg) + *err_msg = "Pipeline mirroring configuration error."; + return status; + } + + /* Input ports. */ + for (i = 0; i < s->n_ports_in; i++) { + status = rte_swx_pipeline_port_in_config(p, + i, + s->port_in_type[i], + s->port_in_params[i]); + if (status) { + if (err_msg) + *err_msg = "Pipeline input port configuration error."; + return status; + } + } + + /* Output ports. */ + for (i = 0; i < s->n_ports_out; i++) { + status = rte_swx_pipeline_port_out_config(p, + i, + s->port_out_type[i], + s->port_out_params[i]); + if (status) { + if (err_msg) + *err_msg = "Pipeline output port configuration error."; + return status; + } + } + + return 0; +} diff --git a/lib/pipeline/rte_swx_pipeline_spec.h b/lib/pipeline/rte_swx_pipeline_spec.h index 707b99ba09..62ac4ecfc4 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.h +++ b/lib/pipeline/rte_swx_pipeline_spec.h @@ -1,6 +1,13 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2022 Intel Corporation */ +#ifndef __INCLUDE_RTE_SWX_PIPELINE_SPEC_H__ +#define __INCLUDE_RTE_SWX_PIPELINE_SPEC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -204,6 +211,38 @@ struct pipeline_spec { uint32_t n_apply; }; +/* + * Mirroring: + * mirroring slots sessions + * + * Input ports: + * port in ethdev rxq bsz + * port in ring bsz + * port in source mempool file loop + * packets + * port in fd mtu mempool bsz + * + * Output ports: + * port out ethdev txq bsz + * port out ring bsz + * port out sink file | none + * port out fd bsz + */ +struct pipeline_iospec { + struct rte_swx_pipeline_mirroring_params mirroring_params; + + uint32_t *port_in_id; + const char **port_in_type; + void **port_in_params; + + uint32_t *port_out_id; + const char **port_out_type; + void **port_out_params; + + uint32_t n_ports_in; + uint32_t n_ports_out; +}; + void pipeline_spec_free(struct pipeline_spec *s); @@ -220,3 +259,22 @@ int pipeline_spec_configure(struct rte_swx_pipeline *p, struct pipeline_spec *s, const char **err_msg); + +void +pipeline_iospec_free(struct pipeline_iospec *s); + +struct pipeline_iospec * +pipeline_iospec_parse(FILE *spec, + uint32_t *err_line, + const char **err_msg); + +int +pipeline_iospec_configure(struct rte_swx_pipeline *p, + struct pipeline_iospec *s, + const char **err_msg); + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Wed Jul 27 23:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114319 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 4C94DA00C4; Thu, 28 Jul 2022 01:02:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 446F142BB1; Thu, 28 Jul 2022 01:01:45 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 2AAA342B75 for ; Thu, 28 Jul 2022 01:01:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962903; x=1690498903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B96s1TUQYXQUFbf2LJ54XtvuQrgnSSS22HsbLwweC8M=; b=bOjFELCsDOm1DW4ik2xgGEz35S3od2LPEzs2bVRNfnMk+/jZ03vmSkJ0 iCRfHS7hZv8+hfKuuCUY1keazMZ3I0+xgIaEcXGyYhWzGV5pYfASlwpO3 cIfxudde1YTukMDB8lc1grgkFdAKgy46kQloaoZZ52sG8hzOcan5TbAiI kc6fgpzgmXyyYzFUluCGqfLnIZ4iPxgUQ/sTbQ/FJnjNSgeUZgugPLAP3 SPA0L5MMwo+L9gMBvbaWt7k5O0DMAnfxZX8xYaEGi/Bl6ndzmmeEefIOx 77ysF7BtUPFkh/TMt3NwCpxFsBym3AtWfJUEGrpY65rrICVUHyM/G3szr A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150913" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150913" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444332" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:39 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 07/17] pipeline: add API for pipeline code generation Date: Wed, 27 Jul 2022 23:01:22 +0000 Message-Id: <20220727230132.601114-7-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 | 1 + 3 files changed, 120 insertions(+) diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index c8ccded4f8..dd5f7107fa 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -20,6 +20,7 @@ #include #include "rte_swx_pipeline_internal.h" +#include "rte_swx_pipeline_spec.h" #define CHECK(condition, err_code) \ do { \ @@ -13581,3 +13582,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, NULL, 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 ef50a0fa70..724607b87c 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -957,6 +957,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 50029aadcf..8d95005a5b 100644 --- a/lib/pipeline/version.map +++ b/lib/pipeline/version.map @@ -148,5 +148,6 @@ EXPERIMENTAL { #added in 22.11 rte_swx_ctl_pipeline_find; + rte_swx_pipeline_codegen; rte_swx_pipeline_find; }; From patchwork Wed Jul 27 23:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114320 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 A243FA00C4; Thu, 28 Jul 2022 01:02:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E1C842BBC; Thu, 28 Jul 2022 01:01:48 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 9434A42BAE for ; Thu, 28 Jul 2022 01:01:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962904; x=1690498904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rMHq8sXj8IPmdHWPEBo/ABaiCJEn99cOCPu+oxWnHws=; b=VJMgYxnUXn9nQq2InESVeZrZfNdaPVGl3P/XuMpHGIGZDoKgXxYNSnnT Vr+kXk1420tDm6R1TYXr5ViYxLX1fSTJVZ5MPMOy2/A7mWy3G/AKDnll7 2s1kEWYjlSZHGzbJrZbFRWIq7UNu40SFQnAIcOV9G8zFf7hC6hetq6B+K Iz6nGK79aF6xg8R0Z6dx/+ZN7h8a2wq6SlgTgty7kiGo69B1mRmXO54L3 9aH3qkyVzDUhVkPcXABQnLWypfpcQaFOyJo/xs98KhKUiX7KYNO5TX/EC +kf4h6TgmbmGkFX97QmMU7GwdXXLfAWogiXTm5V1UKAPmDvWG6M/tk5XR w==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150916" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150916" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444339" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:40 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 08/17] pipeline: add API for shared library-based pipeline build Date: Wed, 27 Jul 2022 23:01:23 +0000 Message-Id: <20220727230132.601114-8-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 | 85 ++++--- lib/pipeline/rte_swx_pipeline.c | 319 +++++++++++---------------- lib/pipeline/rte_swx_pipeline.h | 38 ++-- lib/pipeline/rte_swx_pipeline_spec.c | 51 ----- lib/pipeline/version.map | 2 +- 5 files changed, 208 insertions(+), 287 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index ad553f19ab..f0285675b3 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -984,55 +984,88 @@ cmd_pipeline_port_out(char **tokens, } static const char cmd_pipeline_build_help[] = -"pipeline build \n"; +"pipeline build lib io numa \n"; static void cmd_pipeline_build(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p = NULL; - FILE *spec = NULL; - uint32_t err_line; - const char *err_msg; - int status; + struct rte_swx_pipeline *p = NULL; + struct rte_swx_ctl_pipeline *ctl = NULL; + char *pipeline_name, *lib_file_name, *iospec_file_name; + FILE *iospec_file = NULL; + uint32_t numa_node = 0; + int status = 0; - if (n_tokens != 4) { + /* Parsing. */ + if (n_tokens != 9) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } - p = pipeline_find(obj, tokens[1]); - if (!p || p->ctl) { - snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); + pipeline_name = tokens[1]; + + if (strcmp(tokens[2], "build")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "build"); return; } - spec = fopen(tokens[3], "r"); - if (!spec) { - snprintf(out, out_size, "Cannot open file %s.\n", tokens[3]); + if (strcmp(tokens[3], "lib")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "lib"); return; } - status = rte_swx_pipeline_build_from_spec(p->p, - spec, - &err_line, - &err_msg); - fclose(spec); - if (status) { - snprintf(out, out_size, "Error %d at line %u: %s\n.", - status, err_line, err_msg); + lib_file_name = tokens[4]; + + if (strcmp(tokens[5], "io")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "io"); return; } - p->ctl = rte_swx_ctl_pipeline_create(p->p); - if (!p->ctl) { - snprintf(out, out_size, "Pipeline control create failed."); - rte_swx_pipeline_free(p->p); + iospec_file_name = tokens[6]; + + if (strcmp(tokens[7], "numa")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "numa"); return; } + + if (parser_read_uint32(&numa_node, tokens[8])) { + snprintf(out, out_size, MSG_ARG_INVALID, "numa_node"); + return; + } + + /* I/O spec file open. */ + iospec_file = fopen(iospec_file_name, "r"); + if (!iospec_file) { + snprintf(out, out_size, "Cannot open file \"%s\".\n", iospec_file_name); + return; + } + + status = rte_swx_pipeline_build_from_lib(&p, + pipeline_name, + lib_file_name, + iospec_file, + (int)numa_node); + if (status) { + snprintf(out, out_size, "Pipeline build failed (%d).", status); + goto free; + } + + ctl = rte_swx_ctl_pipeline_create(p); + if (!ctl) { + snprintf(out, out_size, "Pipeline control create failed."); + goto free; + } + +free: + if (status) + rte_swx_pipeline_free(p); + + if (iospec_file) + fclose(iospec_file); } static void diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index dd5f7107fa..12e156b00b 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -9911,9 +9911,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) { @@ -10003,8 +10000,6 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p) p->build_done = 1; - pipeline_compile(p); - return 0; error: @@ -13327,160 +13322,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) @@ -13548,41 +13389,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, @@ -13675,3 +13481,128 @@ rte_swx_pipeline_codegen(FILE *spec_file, return status; } + +int +rte_swx_pipeline_build_from_lib(struct rte_swx_pipeline **pipeline, + const char *name, + const char *lib_file_name, + FILE *iospec_file, + int numa_node) +{ + struct rte_swx_pipeline *p = NULL; + void *lib = NULL; + struct pipeline_iospec *sio = 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 (!pipeline || + !name || + !name[0] || + !lib_file_name || + !lib_file_name[0] || + !iospec_file) { + status = -EINVAL; + goto free; + } + + /* Open the library. */ + lib = dlopen(lib_file_name, RTLD_LAZY); + if (!lib) { + status = -EIO; + goto free; + } + + /* Get the pipeline specification structures. */ + s = dlsym(lib, "pipeline_spec"); + if (!s) { + status = -EINVAL; + goto free; + } + + sio = pipeline_iospec_parse(iospec_file, NULL, NULL); + if (!sio) { + status = -EINVAL; + goto free; + } + + /* Pipeline configuration based on the specification structures. */ + status = rte_swx_pipeline_config(&p, name, numa_node); + if (status) + goto free; + + status = pipeline_iospec_configure(p, sio, NULL); + if (status) + goto free; + + 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; + + *pipeline = p; + +free: + instruction_group_list_free(igl); + + pipeline_iospec_free(sio); + + if (status) { + rte_swx_pipeline_free(p); + + if (lib) + dlclose(lib); + } + + return status; +} diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index 724607b87c..9c629d4118 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -983,30 +983,38 @@ rte_swx_pipeline_codegen(FILE *spec_file, const char **err_msg); /** - * Pipeline build from specification file + * Pipeline build from shared object library * - * @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. + * The shared object library must be built from the C language source code file + * previously generated by the rte_swx_pipeline_codegen() API function. + * + * The pipeline I/O specification file defines the I/O ports of the pipeline. + * + * @param[out] p + * Pipeline handle. Must point to valid memory. Contains valid pipeline handle + * when the function returns successfully. + * @param[in] name + * Pipeline unique name. + * @param[in] lib_file_name + * Shared object library file name. + * @param[in] iospec_file + * Pipeline I/O specification file. + * @param[in] numa_node + * Non-Uniform Memory Access (NUMA) node. * @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 with this name already exists; * -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 *name, + const char *lib_file_name, + FILE *iospec_file, + int numa_node); /** * Pipeline run diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c index f34803793d..3c16daf7de 100644 --- a/lib/pipeline/rte_swx_pipeline_spec.c +++ b/lib/pipeline/rte_swx_pipeline_spec.c @@ -3522,57 +3522,6 @@ 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; -} - static void port_in_params_free(void *params, const char *port_type) { diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map index 8d95005a5b..16806e6802 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,6 +147,7 @@ EXPERIMENTAL { #added in 22.11 rte_swx_ctl_pipeline_find; + rte_swx_pipeline_build_from_lib; rte_swx_pipeline_codegen; rte_swx_pipeline_find; }; From patchwork Wed Jul 27 23:01:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114321 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 C8070A00C4; Thu, 28 Jul 2022 01:02:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43FE742BC2; Thu, 28 Jul 2022 01:01:49 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id D9EF242B7A for ; Thu, 28 Jul 2022 01:01:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962906; x=1690498906; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JszzWG6YpTg73IuGcweOO4hXjXzQIxz92sm+yet532g=; b=UiP3S8o3vAPfCMfym8gw7Ls7WlQhV/VSLaqd/ugaVffUNsmnzwAdbeOT I8453tDqe6f8yzq8wF1KefvS/FyAv6ItoSuSBK0/pLh7mh5/aJxqXSTl2 vUudFz2ei9uGq88FgEMCQmLeGsILmo2GWflZHrFyFYCK+6OcD0uBwJ90o 9Qw4Ov1RPUZ97bzaCaymEevCRCNbySIxTvjmn/uTcEqG4mDpF1w+PYsJk 3C9bPrqHq1o5rUEwxPeB/CtHDvbYGhPZpHSbnN5hx4AYpR+JKUvUnMc72 om592+wbzoBgO7Twf7WrMhDrs9h9W/dBrDmd60FV3NOLvGR++mTXsTGOW A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150920" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150920" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444343" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:41 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 09/17] examples/pipeline: add CLI command for pipeline code generation Date: Wed, 27 Jul 2022 23:01:24 +0000 Message-Id: <20220727230132.601114-9-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 f0285675b3..2b38977be1 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 lib io numa \n"; @@ -3009,6 +3056,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" @@ -3078,6 +3126,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); @@ -3356,6 +3410,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 Wed Jul 27 23:01:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114324 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 C8EFEA00C4; Thu, 28 Jul 2022 01:02:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 348E342BD2; Thu, 28 Jul 2022 01:01:53 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 7F80642B7A for ; Thu, 28 Jul 2022 01:01:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962907; x=1690498907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=95Sbs83qYWkK0R74Y+/x4Gwlb1XhzzVaW6NJKTZu2xg=; b=jmgox41fVN2GwyPAZvZvjlfoksBcdwnnJ/6Li5KwLlzuBWATIuL46pqP EIIEdWGHWmyv4d+IFHsZkHp06GL2pbRKTsD57IB3qrknWXQrNmKz9JQOF YKX2P7ulIEhw3TO/To1n3LXopbjFBo83gArluY8HDP5qOFrGuw6fZcOUd zzcgFYLB2wUSqs9Flf1XtAXU+3yRKPc+Fnf2aT1PZUl0W7ywJ7WqvyDKi 8FX3ef50N+ouo+W4xa67xDb0JJXgVAPaaLDHuSHDqL/AMy1wQsG5mUwm3 olPELBQ3SiR1yNHwrDa5p2b31DVs3GqX0invHi1aj2zRaUIM9Emb4tzOs A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150924" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150924" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444347" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:42 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 10/17] examples/pipeline: add CLI command for shared library build Date: Wed, 27 Jul 2022 23:01:25 +0000 Message-Id: <20220727230132.601114-10-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 | 157 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 4 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 2b38977be1..28cf8d4178 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,140 @@ 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, *cwd = NULL, *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) { + cwd = malloc(MAX_LINE_SIZE); + if (!cwd) { + snprintf(out, out_size, MSG_OUT_OF_MEMORY); + goto free; + } + + install_dir = getcwd(cwd, MAX_LINE_SIZE); + if (!install_dir) { + snprintf(out, out_size, "Error: Path too long.\n"); + goto free; + } + } + + 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(cwd); + free(obj_file); + free(log_file); + free(buffer); +} + static const char cmd_pipeline_build_help[] = "pipeline build lib io numa \n"; @@ -1127,10 +1266,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, @@ -3057,6 +3192,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" @@ -3132,6 +3268,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); @@ -3417,6 +3559,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 Wed Jul 27 23:01:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114322 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 E85EBA00C5; Thu, 28 Jul 2022 01:02:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E8C342BC7; Thu, 28 Jul 2022 01:01:50 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id EB25942B81 for ; Thu, 28 Jul 2022 01:01:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962907; x=1690498907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2R+GVO7r3oN9TqFFRzpvaV99DCKCCGwCt5YuQ4wzHKU=; b=J1f5Nc6tTHpwHID+wqgpJF+IK9bR6FP7F4OZcI5lDNsUjM8tQEqR0MP6 G/eyK5+a7lLpSv+ahcnyrrH/bF9Z1KGf2GW43hU1cpGEudOhxeTPJJPho pgGBxxG4pmGeUy1e9nzvj4he96K63tF7aH3oox5eTnbshgyBb6bSMWPta sPhW5v8kMrs70EiOukeNMMEdd2tb46sL2css6EDWSfJczi+chy6wFjOfZ cnsQ/ywQIZK2NL7Tt5B5xo0WJGqLXJ6eZWGUHLYRx4mOmxVI3W85/tlbp whCN/FbFm0qzcuo0Zzj6w5ZWvAqg1gO9LuRfdvYAtQPt5/2NkFpKpYcKn w==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150925" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150925" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444351" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:43 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 11/17] examples/pipeline: remove the obsolete pipeline create CLI command Date: Wed, 27 Jul 2022 23:01:26 +0000 Message-Id: <20220727230132.601114-11-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 The pipeline configuration is now done through the I/O specification file, hence this CLI command is no longer needed. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 47 ----------------------------------------- 1 file changed, 47 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 28cf8d4178..7b725a9c27 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -523,39 +523,6 @@ cmd_tap(char **tokens, } } -static const char cmd_pipeline_create_help[] = -"pipeline create \n"; - -static void -cmd_pipeline_create(char **tokens, - uint32_t n_tokens, - char *out, - size_t out_size, - void *obj) -{ - struct pipeline *p; - char *name; - uint32_t numa_node; - - if (n_tokens != 4) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } - - name = tokens[1]; - - if (parser_read_uint32(&numa_node, tokens[3]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "numa_node"); - return; - } - - p = pipeline_create(obj, name, (int)numa_node); - if (!p) { - snprintf(out, out_size, "pipeline create error."); - return; - } -} - static const char cmd_pipeline_port_in_help[] = "pipeline port in \n" " link rxq bsz \n" @@ -3188,7 +3155,6 @@ cmd_help(char **tokens, "\tmempool\n" "\tlink\n" "\ttap\n" - "\tpipeline create\n" "\tpipeline port in\n" "\tpipeline port out\n" "\tpipeline codegen\n" @@ -3241,12 +3207,6 @@ cmd_help(char **tokens, return; } - if ((strcmp(tokens[0], "pipeline") == 0) && - (n_tokens == 2) && (strcmp(tokens[1], "create") == 0)) { - snprintf(out, out_size, "\n%s\n", cmd_pipeline_create_help); - return; - } - if ((strcmp(tokens[0], "pipeline") == 0) && (n_tokens == 3) && (strcmp(tokens[1], "port") == 0)) { if (strcmp(tokens[2], "in") == 0) { @@ -3529,13 +3489,6 @@ cli_process(char *in, char *out, size_t out_size, void *obj) } if (strcmp(tokens[0], "pipeline") == 0) { - if ((n_tokens >= 3) && - (strcmp(tokens[2], "create") == 0)) { - cmd_pipeline_create(tokens, n_tokens, out, out_size, - obj); - return; - } - if ((n_tokens >= 4) && (strcmp(tokens[2], "port") == 0) && (strcmp(tokens[3], "in") == 0)) { From patchwork Wed Jul 27 23:01:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114325 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 2734DA00C4; Thu, 28 Jul 2022 01:02:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FF0342BE2; Thu, 28 Jul 2022 01:01:54 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 2EE8042BB7 for ; Thu, 28 Jul 2022 01:01:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962908; x=1690498908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1pxNzdR4+Ogc2O+1sQCAmm9gE9nlMHT6QsLEbNxvYjk=; b=aQ9lkl4Gk5CQssujuRkMxImbLN+HotkUAiIjFx1/pbP+VEKas2FaskwB 5S5g1arS/a1HPZq8Iegjg/hjuUaeT224Hwfzto+pUNA9YnphkJKzExsF4 4+dbaq0A7d1D+mD10twkg8/v0cBoQbGMezn76TZvbW6m4om/P6O2+RRiK LXZp76JzJFSIn9H+PFHQz0nmoEMF77sahi3swZpslL2A/YkGPm8VFQAwG kqOpC06IPyTczeNEC/1c/HCMpAc4qlj1mRlKL6Nq1eLzKyS6OKbBszjvs Xb0y2Oz5VHEy1Tz1HmpAi+SedJ5Tg3y9zEbphntNVXX1fwlfNYzeOuDgi A==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="314150929" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="314150929" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444365" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:44 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 12/17] examples/pipeline: remove the obsolete port configuration CLI commands Date: Wed, 27 Jul 2022 23:01:27 +0000 Message-Id: <20220727230132.601114-12-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 The pipeline I/O ports configuration is now done through the I/O specification file, hence these CLI commands are no longer needed. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 465 ---------------------------------------- 1 file changed, 465 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 7b725a9c27..b26e73c706 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -523,438 +523,6 @@ cmd_tap(char **tokens, } } -static const char cmd_pipeline_port_in_help[] = -"pipeline port in \n" -" link rxq bsz \n" -" ring bsz \n" -" | source loop \n" -" | tap mempool mtu bsz \n"; - -static void -cmd_pipeline_port_in(char **tokens, - uint32_t n_tokens, - char *out, - size_t out_size, - void *obj) -{ - struct pipeline *p; - int status; - uint32_t port_id = 0, t0; - - if (n_tokens < 6) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } - - p = pipeline_find(obj, tokens[1]); - if (!p || p->ctl) { - snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); - return; - } - - if (strcmp(tokens[2], "port") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port"); - return; - } - - if (strcmp(tokens[3], "in") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in"); - return; - } - - if (parser_read_uint32(&port_id, tokens[4]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "port_id"); - return; - } - - t0 = 5; - - if (strcmp(tokens[t0], "link") == 0) { - struct rte_swx_port_ethdev_reader_params params; - struct link *link; - - if (n_tokens < t0 + 6) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port in link"); - return; - } - - link = link_find(obj, tokens[t0 + 1]); - if (!link) { - snprintf(out, out_size, MSG_ARG_INVALID, - "link_name"); - return; - } - params.dev_name = link->dev_name; - - if (strcmp(tokens[t0 + 2], "rxq") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); - return; - } - - if (parser_read_uint16(¶ms.queue_id, tokens[t0 + 3]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, - "queue_id"); - return; - } - - if (strcmp(tokens[t0 + 4], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 5])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 6; - - status = rte_swx_pipeline_port_in_config(p->p, - port_id, - "ethdev", - ¶ms); - } else if (strcmp(tokens[t0], "ring") == 0) { - struct rte_swx_port_ring_reader_params params; - struct ring *ring; - - if (n_tokens < t0 + 4) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port in ring"); - return; - } - - ring = ring_find(obj, tokens[t0 + 1]); - if (!ring) { - snprintf(out, out_size, MSG_ARG_INVALID, - "ring_name"); - return; - } - params.name = ring->name; - - if (strcmp(tokens[t0 + 2], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 3])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 4; - - status = rte_swx_pipeline_port_in_config(p->p, - port_id, - "ring", - ¶ms); - } else if (strcmp(tokens[t0], "source") == 0) { - struct rte_swx_port_source_params params; - struct mempool *mp; - - if (n_tokens < t0 + 5) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port in source"); - return; - } - - mp = mempool_find(obj, tokens[t0 + 1]); - if (!mp) { - snprintf(out, out_size, MSG_ARG_INVALID, - "mempool_name"); - return; - } - params.pool = mp->m; - - params.file_name = tokens[t0 + 2]; - - if (strcmp(tokens[t0 + 3], "loop") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "loop"); - return; - } - - if (parser_read_uint64(¶ms.n_loops, tokens[t0 + 4])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "n_loops"); - return; - } - - t0 += 5; - - status = rte_swx_pipeline_port_in_config(p->p, - port_id, - "source", - ¶ms); - } else if (strcmp(tokens[t0], "tap") == 0) { - struct rte_swx_port_fd_reader_params params; - struct tap *tap; - struct mempool *mp; - - if (n_tokens < t0 + 8) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port in tap"); - return; - } - - tap = tap_find(obj, tokens[t0 + 1]); - if (!tap) { - snprintf(out, out_size, MSG_ARG_INVALID, - "tap_name"); - return; - } - params.fd = tap->fd; - - if (strcmp(tokens[t0 + 2], "mempool") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, - "mempool"); - return; - } - - mp = mempool_find(obj, tokens[t0 + 3]); - if (!mp) { - snprintf(out, out_size, MSG_ARG_INVALID, - "mempool_name"); - return; - } - params.mempool = mp->m; - - if (strcmp(tokens[t0 + 4], "mtu") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, - "mtu"); - return; - } - - if (parser_read_uint32(¶ms.mtu, tokens[t0 + 5]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "mtu"); - return; - } - - if (strcmp(tokens[t0 + 6], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 7])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 8; - - status = rte_swx_pipeline_port_in_config(p->p, - port_id, - "fd", - ¶ms); - - } else { - snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); - return; - } - - if (status) { - snprintf(out, out_size, "port in error."); - return; - } - - if (n_tokens != t0) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } -} - -static const char cmd_pipeline_port_out_help[] = -"pipeline port out \n" -" link txq bsz \n" -" ring bsz \n" -" | sink | none\n" -" | tap bsz \n"; - -static void -cmd_pipeline_port_out(char **tokens, - uint32_t n_tokens, - char *out, - size_t out_size, - void *obj) -{ - struct pipeline *p; - int status; - uint32_t port_id = 0, t0; - - if (n_tokens < 6) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } - - p = pipeline_find(obj, tokens[1]); - if (!p || p->ctl) { - snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); - return; - } - - if (strcmp(tokens[2], "port") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port"); - return; - } - - if (strcmp(tokens[3], "out") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out"); - return; - } - - if (parser_read_uint32(&port_id, tokens[4]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "port_id"); - return; - } - - t0 = 5; - - if (strcmp(tokens[t0], "link") == 0) { - struct rte_swx_port_ethdev_writer_params params; - struct link *link; - - if (n_tokens < t0 + 6) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port out link"); - return; - } - - link = link_find(obj, tokens[t0 + 1]); - if (!link) { - snprintf(out, out_size, MSG_ARG_INVALID, - "link_name"); - return; - } - params.dev_name = link->dev_name; - - if (strcmp(tokens[t0 + 2], "txq") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq"); - return; - } - - if (parser_read_uint16(¶ms.queue_id, tokens[t0 + 3]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, - "queue_id"); - return; - } - - if (strcmp(tokens[t0 + 4], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 5])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 6; - - status = rte_swx_pipeline_port_out_config(p->p, - port_id, - "ethdev", - ¶ms); - } else if (strcmp(tokens[t0], "ring") == 0) { - struct rte_swx_port_ring_writer_params params; - struct ring *ring; - - if (n_tokens < t0 + 4) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port out link"); - return; - } - - ring = ring_find(obj, tokens[t0 + 1]); - if (!ring) { - snprintf(out, out_size, MSG_ARG_INVALID, - "ring_name"); - return; - } - params.name = ring->name; - - if (strcmp(tokens[t0 + 2], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 3])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 4; - - status = rte_swx_pipeline_port_out_config(p->p, - port_id, - "ring", - ¶ms); - } else if (strcmp(tokens[t0], "sink") == 0) { - struct rte_swx_port_sink_params params; - - params.file_name = strcmp(tokens[t0 + 1], "none") ? - tokens[t0 + 1] : NULL; - - t0 += 2; - - status = rte_swx_pipeline_port_out_config(p->p, - port_id, - "sink", - ¶ms); - } else if (strcmp(tokens[t0], "tap") == 0) { - struct rte_swx_port_fd_writer_params params; - struct tap *tap; - - if (n_tokens < t0 + 4) { - snprintf(out, out_size, MSG_ARG_MISMATCH, - "pipeline port out tap"); - return; - } - - tap = tap_find(obj, tokens[t0 + 1]); - if (!tap) { - snprintf(out, out_size, MSG_ARG_INVALID, - "tap_name"); - return; - } - params.fd = tap->fd; - - if (strcmp(tokens[t0 + 2], "bsz") != 0) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "bsz"); - return; - } - - if (parser_read_uint32(¶ms.burst_size, tokens[t0 + 3])) { - snprintf(out, out_size, MSG_ARG_INVALID, - "burst_size"); - return; - } - - t0 += 4; - - status = rte_swx_pipeline_port_out_config(p->p, - port_id, - "fd", - ¶ms); - } else { - snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); - return; - } - - if (status) { - snprintf(out, out_size, "port out error."); - return; - } - - if (n_tokens != t0) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } -} - static const char cmd_pipeline_codegen_help[] = "pipeline codegen \n"; @@ -3155,8 +2723,6 @@ cmd_help(char **tokens, "\tmempool\n" "\tlink\n" "\ttap\n" - "\tpipeline port in\n" - "\tpipeline port out\n" "\tpipeline codegen\n" "\tpipeline libbuild\n" "\tpipeline build\n" @@ -3207,21 +2773,6 @@ cmd_help(char **tokens, return; } - if ((strcmp(tokens[0], "pipeline") == 0) && - (n_tokens == 3) && (strcmp(tokens[1], "port") == 0)) { - if (strcmp(tokens[2], "in") == 0) { - snprintf(out, out_size, "\n%s\n", - cmd_pipeline_port_in_help); - return; - } - - if (strcmp(tokens[2], "out") == 0) { - snprintf(out, out_size, "\n%s\n", - cmd_pipeline_port_out_help); - return; - } - } - 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); @@ -3489,22 +3040,6 @@ cli_process(char *in, char *out, size_t out_size, void *obj) } if (strcmp(tokens[0], "pipeline") == 0) { - if ((n_tokens >= 4) && - (strcmp(tokens[2], "port") == 0) && - (strcmp(tokens[3], "in") == 0)) { - cmd_pipeline_port_in(tokens, n_tokens, out, out_size, - obj); - return; - } - - if ((n_tokens >= 4) && - (strcmp(tokens[2], "port") == 0) && - (strcmp(tokens[3], "out") == 0)) { - cmd_pipeline_port_out(tokens, n_tokens, out, out_size, - obj); - return; - } - if ((n_tokens >= 3) && (strcmp(tokens[1], "codegen") == 0)) { cmd_pipeline_codegen(tokens, n_tokens, out, out_size, From patchwork Wed Jul 27 23:01:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114323 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 97BCEA00C4; Thu, 28 Jul 2022 01:02:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5198E42BD9; Thu, 28 Jul 2022 01:01:52 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id C260342B81 for ; Thu, 28 Jul 2022 01:01:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962907; x=1690498907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7DIJdGBhhTi2g2X6BRxSQ0emsktRdh2ueXI7HokequQ=; b=CKIKNEg7ngRxA7OV5uwEqwr3MllWUxBbV3iIMfb9cRUAsFFDKxGXca2E Xrc2gEzK0i5aujp26PhZT/H0v8rcK6Ztk/4EV08ArQ7U5bHf3Cycrf0wF f9NV1v0nghDGekTrmMm6lVTrkagt92xBtxz9A/0NMWJAzbj50VDOUqG2F soFU993vWKx1/tui0CC7/WkETKOwC7vnUR5bsyYJXkCZeMJO2srZNVpzb ipEOvG3gf9sMCpItFPiGdIfuYuts4u+inhiKs/hmluaMz3QbutMGr+i6N QYTQXhU34XkVXnxC+SXP7zeATqYnqXy+pmWDqvIOUFX6aYY2yLRhBEmsv w==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135832" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135832" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444377" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:45 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 13/17] examples/pipeline: remove the obsolete mirroring configuration CLI command Date: Wed, 27 Jul 2022 23:01:28 +0000 Message-Id: <20220727230132.601114-13-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 The pipeline mirroring configuration is done through the I/O specification file, so this CLI command is no longer needed. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 76 ----------------------------------------- 1 file changed, 76 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index b26e73c706..fa828c008b 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -2457,68 +2457,6 @@ cmd_pipeline_stats(char **tokens, } } -static const char cmd_pipeline_mirror_help[] = -"pipeline mirror slots sessions \n"; - -static void -cmd_pipeline_mirror(char **tokens, - uint32_t n_tokens, - char *out, - size_t out_size, - void *obj) -{ - struct rte_swx_pipeline_mirroring_params params; - struct pipeline *p; - int status; - - if (n_tokens != 7) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } - - if (strcmp(tokens[0], "pipeline")) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline"); - return; - } - - p = pipeline_find(obj, tokens[1]); - if (!p) { - snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); - return; - } - - if (strcmp(tokens[2], "mirror")) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mirror"); - return; - } - - if (strcmp(tokens[3], "slots")) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "slots"); - return; - } - - if (parser_read_uint32(¶ms.n_slots, tokens[4])) { - snprintf(out, out_size, MSG_ARG_INVALID, "n_slots"); - return; - } - - if (strcmp(tokens[5], "sessions")) { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "sessions"); - return; - } - - if (parser_read_uint32(¶ms.n_sessions, tokens[6])) { - snprintf(out, out_size, MSG_ARG_INVALID, "n_sessions"); - return; - } - - status = rte_swx_pipeline_mirroring_config(p->p, ¶ms); - if (status) { - snprintf(out, out_size, "Command failed!\n"); - return; - } -} - static const char cmd_pipeline_mirror_session_help[] = "pipeline mirror session port clone fast | slow " "truncate \n"; @@ -2746,7 +2684,6 @@ cmd_help(char **tokens, "\tpipeline meter set\n" "\tpipeline meter stats\n" "\tpipeline stats\n" - "\tpipeline mirror\n" "\tpipeline mirror session\n" "\tthread pipeline enable\n" "\tthread pipeline disable\n\n"); @@ -2958,12 +2895,6 @@ cmd_help(char **tokens, return; } - if (!strcmp(tokens[0], "pipeline") && - (n_tokens == 2) && !strcmp(tokens[1], "mirror")) { - snprintf(out, out_size, "\n%s\n", cmd_pipeline_mirror_help); - return; - } - if (!strcmp(tokens[0], "pipeline") && (n_tokens == 3) && !strcmp(tokens[1], "mirror") && !strcmp(tokens[2], "session")) { @@ -3217,13 +3148,6 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } - if ((n_tokens >= 4) && - (strcmp(tokens[2], "mirror") == 0) && - (strcmp(tokens[3], "slots") == 0)) { - cmd_pipeline_mirror(tokens, n_tokens, out, out_size, obj); - return; - } - if ((n_tokens >= 4) && (strcmp(tokens[2], "mirror") == 0) && (strcmp(tokens[3], "session") == 0)) { From patchwork Wed Jul 27 23:01:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114326 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 84E55A00C4; Thu, 28 Jul 2022 01:03:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 455C742BE6; Thu, 28 Jul 2022 01:01:55 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id C1FA242BBB for ; Thu, 28 Jul 2022 01:01:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962908; x=1690498908; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mdd7xobB3yYeOf0ALMuS8NLNlQj9cuZS1V80eTZviNw=; b=jZVrjj4mRB+qmyEqNiqUDIynF7B7BaihrGIIuuUpecLkB7Uuaoh28gRS 2Pdatn8sHQWXd7Li/3uN3sQixACEjuyzHwQgD+XsVlYswYxYL6qlYnGYY b9ldC2x/t9E3IUyWHByhc5a/9Gn5iMr81gMT/K0+65rah+k42VMObbOnB Nxy6MApaJLG1eUv2SvydnixtV9Afl6bw12RDkV4veHtGsLiTDkxKXO4vz VifHm+yDSQZaF6XA7lakCHAxYErDj0eRYFf+A9hlQenWE1U3FZUmVsq4a 4QdE2m4YypwoTsJfKe8max8XwM8TlyAybb6MNbAh1ndEKZgBOJNyuT1Bb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135835" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135835" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444396" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:46 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 14/17] examples/pipeline: use the pipeline name query API Date: Wed, 27 Jul 2022 23:01:29 +0000 Message-Id: <20220727230132.601114-14-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 Convert the CLI commands to use the pipeline name query API and remove the linked list of pipeline objects previously maintained by the application. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 268 ++++++++++++++++++++----------------- examples/pipeline/obj.c | 67 ---------- examples/pipeline/obj.h | 24 ---- examples/pipeline/thread.c | 65 ++++----- examples/pipeline/thread.h | 9 +- 5 files changed, 175 insertions(+), 258 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index fa828c008b..f48ff326be 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -858,9 +858,9 @@ cmd_pipeline_table_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -872,8 +872,8 @@ cmd_pipeline_table_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -887,7 +887,7 @@ cmd_pipeline_table_add(char **tokens, return; } - status = pipeline_table_entries_add(p->ctl, + status = pipeline_table_entries_add(ctl, table_name, file, &file_line_number); @@ -956,9 +956,9 @@ cmd_pipeline_table_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -970,8 +970,8 @@ cmd_pipeline_table_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -985,7 +985,7 @@ cmd_pipeline_table_delete(char **tokens, return; } - status = pipeline_table_entries_delete(p->ctl, + status = pipeline_table_entries_delete(ctl, table_name, file, &file_line_number); @@ -1054,9 +1054,9 @@ cmd_pipeline_table_default(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1068,8 +1068,8 @@ cmd_pipeline_table_default(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1083,7 +1083,7 @@ cmd_pipeline_table_default(char **tokens, return; } - status = pipeline_table_default_entry_add(p->ctl, + status = pipeline_table_default_entry_add(ctl, table_name, file, &file_line_number); @@ -1103,9 +1103,9 @@ cmd_pipeline_table_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *table_name; FILE *file = NULL; int status; @@ -1116,8 +1116,8 @@ cmd_pipeline_table_show(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1129,7 +1129,7 @@ cmd_pipeline_table_show(char **tokens, return; } - status = rte_swx_ctl_pipeline_table_fprintf(file, p->ctl, table_name); + status = rte_swx_ctl_pipeline_table_fprintf(file, ctl, table_name); if (status) snprintf(out, out_size, MSG_ARG_INVALID, "table_name"); @@ -1145,9 +1145,9 @@ cmd_pipeline_selector_group_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; uint32_t group_id; int status; @@ -1158,8 +1158,8 @@ cmd_pipeline_selector_group_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1177,7 +1177,7 @@ cmd_pipeline_selector_group_add(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_group_add(p->ctl, + status = rte_swx_ctl_pipeline_selector_group_add(ctl, selector_name, &group_id); if (status) @@ -1194,9 +1194,9 @@ cmd_pipeline_selector_group_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; uint32_t group_id; int status; @@ -1207,8 +1207,8 @@ cmd_pipeline_selector_group_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1231,7 +1231,7 @@ cmd_pipeline_selector_group_delete(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_group_delete(p->ctl, + status = rte_swx_ctl_pipeline_selector_group_delete(ctl, selector_name, group_id); if (status) @@ -1402,9 +1402,9 @@ cmd_pipeline_selector_group_member_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1416,8 +1416,8 @@ cmd_pipeline_selector_group_member_add(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1443,7 +1443,7 @@ cmd_pipeline_selector_group_member_add(char **tokens, return; } - status = pipeline_selector_group_members_add(p->ctl, + status = pipeline_selector_group_members_add(ctl, selector_name, file, &file_line_number); @@ -1512,9 +1512,9 @@ cmd_pipeline_selector_group_member_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1526,8 +1526,8 @@ cmd_pipeline_selector_group_member_delete(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1553,7 +1553,7 @@ cmd_pipeline_selector_group_member_delete(char **tokens, return; } - status = pipeline_selector_group_members_delete(p->ctl, + status = pipeline_selector_group_members_delete(ctl, selector_name, file, &file_line_number); @@ -1573,9 +1573,9 @@ cmd_pipeline_selector_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *selector_name; FILE *file = NULL; int status; @@ -1586,8 +1586,8 @@ cmd_pipeline_selector_show(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1600,7 +1600,7 @@ cmd_pipeline_selector_show(char **tokens, return; } - status = rte_swx_ctl_pipeline_selector_fprintf(file, p->ctl, selector_name); + status = rte_swx_ctl_pipeline_selector_fprintf(file, ctl, selector_name); if (status) snprintf(out, out_size, MSG_ARG_INVALID, "selector_name"); @@ -1665,9 +1665,9 @@ cmd_pipeline_learner_default(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name, *learner_name, *file_name; FILE *file = NULL; uint32_t file_line_number = 0; @@ -1679,8 +1679,8 @@ cmd_pipeline_learner_default(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1694,7 +1694,7 @@ cmd_pipeline_learner_default(char **tokens, return; } - status = pipeline_learner_default_entry_add(p->ctl, + status = pipeline_learner_default_entry_add(ctl, learner_name, file, &file_line_number); @@ -1714,9 +1714,9 @@ cmd_pipeline_commit(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name; int status; @@ -1726,13 +1726,13 @@ cmd_pipeline_commit(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } - status = rte_swx_ctl_pipeline_commit(p->ctl, 1); + status = rte_swx_ctl_pipeline_commit(ctl, 1); if (status) snprintf(out, out_size, "Commit failed. " "Use \"commit\" to retry or \"abort\" to discard the pending work.\n"); @@ -1746,9 +1746,9 @@ cmd_pipeline_abort(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_ctl_pipeline *ctl; char *pipeline_name; if (n_tokens != 3) { @@ -1757,13 +1757,13 @@ cmd_pipeline_abort(char **tokens, } pipeline_name = tokens[1]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + ctl = rte_swx_ctl_pipeline_find(pipeline_name); + if (!ctl) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } - rte_swx_ctl_pipeline_abort(p->ctl); + rte_swx_ctl_pipeline_abort(ctl); } static const char cmd_pipeline_regrd_help[] = @@ -1774,9 +1774,9 @@ cmd_pipeline_regrd(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint64_t value; uint32_t idx; @@ -1787,8 +1787,8 @@ cmd_pipeline_regrd(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1805,7 +1805,7 @@ cmd_pipeline_regrd(char **tokens, return; } - status = rte_swx_ctl_pipeline_regarray_read(p->p, name, idx, &value); + status = rte_swx_ctl_pipeline_regarray_read(p, name, idx, &value); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1822,9 +1822,9 @@ cmd_pipeline_regwr(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint64_t value; uint32_t idx; @@ -1835,8 +1835,8 @@ cmd_pipeline_regwr(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1858,7 +1858,7 @@ cmd_pipeline_regwr(char **tokens, return; } - status = rte_swx_ctl_pipeline_regarray_write(p->p, name, idx, value); + status = rte_swx_ctl_pipeline_regarray_write(p, name, idx, value); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1874,10 +1874,10 @@ cmd_pipeline_meter_profile_add(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_meter_trtcm_params params; - struct pipeline *p; + struct rte_swx_pipeline *p; const char *profile_name; int status; @@ -1886,8 +1886,8 @@ cmd_pipeline_meter_profile_add(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1949,7 +1949,7 @@ cmd_pipeline_meter_profile_add(char **tokens, return; } - status = rte_swx_ctl_meter_profile_add(p->p, profile_name, ¶ms); + status = rte_swx_ctl_meter_profile_add(p, profile_name, ¶ms); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -1964,9 +1964,9 @@ cmd_pipeline_meter_profile_delete(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *profile_name; int status; @@ -1975,8 +1975,8 @@ cmd_pipeline_meter_profile_delete(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -1998,7 +1998,7 @@ cmd_pipeline_meter_profile_delete(char **tokens, return; } - status = rte_swx_ctl_meter_profile_delete(p->p, profile_name); + status = rte_swx_ctl_meter_profile_delete(p, profile_name); if (status) { snprintf(out, out_size, "Command failed.\n"); return; @@ -2014,9 +2014,9 @@ cmd_pipeline_meter_reset(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint32_t idx0 = 0, idx1 = 0; @@ -2025,8 +2025,8 @@ cmd_pipeline_meter_reset(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2066,7 +2066,7 @@ cmd_pipeline_meter_reset(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_reset(p->p, name, idx0); + status = rte_swx_ctl_meter_reset(p, name, idx0); if (status) { snprintf(out, out_size, "Command failed for index %u.\n", idx0); return; @@ -2083,9 +2083,9 @@ cmd_pipeline_meter_set(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name, *profile_name; uint32_t idx0 = 0, idx1 = 0; @@ -2094,8 +2094,8 @@ cmd_pipeline_meter_set(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2142,7 +2142,7 @@ cmd_pipeline_meter_set(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_set(p->p, name, idx0, profile_name); + status = rte_swx_ctl_meter_set(p, name, idx0, profile_name); if (status) { snprintf(out, out_size, "Command failed for index %u.\n", idx0); return; @@ -2159,10 +2159,10 @@ cmd_pipeline_meter_stats(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_ctl_meter_stats stats; - struct pipeline *p; + struct rte_swx_pipeline *p; const char *name; uint32_t idx0 = 0, idx1 = 0; @@ -2171,8 +2171,8 @@ cmd_pipeline_meter_stats(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2235,7 +2235,7 @@ cmd_pipeline_meter_stats(char **tokens, for ( ; idx0 <= idx1; idx0++) { int status; - status = rte_swx_ctl_meter_stats_read(p->p, name, idx0, &stats); + status = rte_swx_ctl_meter_stats_read(p, name, idx0, &stats); if (status) { snprintf(out, out_size, "Pipeline meter stats error at index %u.\n", idx0); out_size -= strlen(out); @@ -2265,10 +2265,10 @@ cmd_pipeline_stats(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_ctl_pipeline_info info; - struct pipeline *p; + struct rte_swx_pipeline *p; uint32_t i; int status; @@ -2277,8 +2277,8 @@ cmd_pipeline_stats(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2288,7 +2288,7 @@ cmd_pipeline_stats(char **tokens, return; } - status = rte_swx_ctl_pipeline_info_get(p->p, &info); + status = rte_swx_ctl_pipeline_info_get(p, &info); if (status) { snprintf(out, out_size, "Pipeline info get error."); return; @@ -2301,7 +2301,7 @@ cmd_pipeline_stats(char **tokens, for (i = 0; i < info.n_ports_in; i++) { struct rte_swx_port_in_stats stats; - rte_swx_ctl_pipeline_port_in_stats_read(p->p, i, &stats); + rte_swx_ctl_pipeline_port_in_stats_read(p, i, &stats); snprintf(out, out_size, "\tPort %u:" " packets %" PRIu64 @@ -2319,7 +2319,7 @@ cmd_pipeline_stats(char **tokens, for (i = 0; i < info.n_ports_out; i++) { struct rte_swx_port_out_stats stats; - rte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats); + rte_swx_ctl_pipeline_port_out_stats_read(p, i, &stats); if (i != info.n_ports_out - 1) snprintf(out, out_size, "\tPort %u:", i); @@ -2358,13 +2358,13 @@ cmd_pipeline_stats(char **tokens, }; uint32_t j; - status = rte_swx_ctl_table_info_get(p->p, i, &table_info); + status = rte_swx_ctl_table_info_get(p, i, &table_info); if (status) { snprintf(out, out_size, "Table info get error."); return; } - status = rte_swx_ctl_pipeline_table_stats_read(p->p, table_info.name, &stats); + status = rte_swx_ctl_pipeline_table_stats_read(p, table_info.name, &stats); if (status) { snprintf(out, out_size, "Table stats read error."); return; @@ -2382,7 +2382,7 @@ cmd_pipeline_stats(char **tokens, for (j = 0; j < info.n_actions; j++) { struct rte_swx_ctl_action_info action_info; - status = rte_swx_ctl_action_info_get(p->p, j, &action_info); + status = rte_swx_ctl_action_info_get(p, j, &action_info); if (status) { snprintf(out, out_size, "Action info get error."); return; @@ -2410,13 +2410,13 @@ cmd_pipeline_stats(char **tokens, }; uint32_t j; - status = rte_swx_ctl_learner_info_get(p->p, i, &learner_info); + status = rte_swx_ctl_learner_info_get(p, i, &learner_info); if (status) { snprintf(out, out_size, "Learner table info get error."); return; } - status = rte_swx_ctl_pipeline_learner_stats_read(p->p, learner_info.name, &stats); + status = rte_swx_ctl_pipeline_learner_stats_read(p, learner_info.name, &stats); if (status) { snprintf(out, out_size, "Learner table stats read error."); return; @@ -2442,7 +2442,7 @@ cmd_pipeline_stats(char **tokens, for (j = 0; j < info.n_actions; j++) { struct rte_swx_ctl_action_info action_info; - status = rte_swx_ctl_action_info_get(p->p, j, &action_info); + status = rte_swx_ctl_action_info_get(p, j, &action_info); if (status) { snprintf(out, out_size, "Action info get error."); return; @@ -2466,10 +2466,10 @@ cmd_pipeline_mirror_session(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { struct rte_swx_pipeline_mirroring_session_params params; - struct pipeline *p; + struct rte_swx_pipeline *p; uint32_t session_id = 0; int status; @@ -2483,8 +2483,8 @@ cmd_pipeline_mirror_session(char **tokens, return; } - p = pipeline_find(obj, tokens[1]); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(tokens[1]); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2538,7 +2538,7 @@ cmd_pipeline_mirror_session(char **tokens, return; } - status = rte_swx_ctl_pipeline_mirroring_session_set(p->p, session_id, ¶ms); + status = rte_swx_ctl_pipeline_mirroring_session_set(p, session_id, ¶ms); if (status) { snprintf(out, out_size, "Command failed!\n"); return; @@ -2546,21 +2546,25 @@ cmd_pipeline_mirror_session(char **tokens, } static const char cmd_thread_pipeline_enable_help[] = -"thread pipeline enable\n"; +"thread pipeline enable [ period ]\n"; + +#ifndef TIMER_PERIOD_MS_DEFAULT +#define TIMER_PERIOD_MS_DEFAULT 10 +#endif static void cmd_thread_pipeline_enable(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { char *pipeline_name; - struct pipeline *p; - uint32_t thread_id; + struct rte_swx_pipeline *p; + uint32_t thread_id, timer_period_ms = TIMER_PERIOD_MS_DEFAULT; int status; - if (n_tokens != 5) { + if ((n_tokens != 5) && (n_tokens != 7)) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } @@ -2576,8 +2580,8 @@ cmd_thread_pipeline_enable(char **tokens, } pipeline_name = tokens[3]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(pipeline_name); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2587,7 +2591,19 @@ cmd_thread_pipeline_enable(char **tokens, return; } - status = thread_pipeline_enable(thread_id, obj, pipeline_name); + if (n_tokens == 7) { + if (strcmp(tokens[5], "period") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, "period"); + return; + } + + if (parser_read_uint32(&timer_period_ms, tokens[6]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "timer_period_ms"); + return; + } + } + + status = thread_pipeline_enable(thread_id, p, timer_period_ms); if (status) { snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable"); return; @@ -2602,9 +2618,9 @@ cmd_thread_pipeline_disable(char **tokens, uint32_t n_tokens, char *out, size_t out_size, - void *obj) + void *obj __rte_unused) { - struct pipeline *p; + struct rte_swx_pipeline *p; char *pipeline_name; uint32_t thread_id; int status; @@ -2625,8 +2641,8 @@ cmd_thread_pipeline_disable(char **tokens, } pipeline_name = tokens[3]; - p = pipeline_find(obj, pipeline_name); - if (!p || !p->ctl) { + p = rte_swx_pipeline_find(pipeline_name); + if (!p) { snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); return; } @@ -2636,7 +2652,7 @@ cmd_thread_pipeline_disable(char **tokens, return; } - status = thread_pipeline_disable(thread_id, obj, pipeline_name); + status = thread_pipeline_disable(thread_id, p); if (status) { snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline disable"); diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index 967342c580..d1f519180e 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "obj.h" @@ -41,11 +40,6 @@ TAILQ_HEAD(ring_list, ring); */ TAILQ_HEAD(tap_list, tap); -/* - * pipeline - */ -TAILQ_HEAD(pipeline_list, pipeline); - /* * obj */ @@ -53,7 +47,6 @@ struct obj { struct mempool_list mempool_list; struct link_list link_list; struct ring_list ring_list; - struct pipeline_list pipeline_list; struct tap_list tap_list; }; @@ -513,65 +506,6 @@ tap_create(struct obj *obj, const char *name) #endif -/* - * pipeline - */ -#ifndef PIPELINE_MSGQ_SIZE -#define PIPELINE_MSGQ_SIZE 64 -#endif - -struct pipeline * -pipeline_create(struct obj *obj, const char *name, int numa_node) -{ - struct pipeline *pipeline; - struct rte_swx_pipeline *p = NULL; - int status; - - /* Check input params */ - if ((name == NULL) || - pipeline_find(obj, name)) - return NULL; - - /* Resource create */ - status = rte_swx_pipeline_config(&p, name, numa_node); - if (status) - goto error; - - /* Node allocation */ - pipeline = calloc(1, sizeof(struct pipeline)); - if (pipeline == NULL) - goto error; - - /* Node fill in */ - strlcpy(pipeline->name, name, sizeof(pipeline->name)); - pipeline->p = p; - pipeline->timer_period_ms = 10; - - /* Node add to list */ - TAILQ_INSERT_TAIL(&obj->pipeline_list, pipeline, node); - - return pipeline; - -error: - rte_swx_pipeline_free(p); - return NULL; -} - -struct pipeline * -pipeline_find(struct obj *obj, const char *name) -{ - struct pipeline *pipeline; - - if (!obj || !name) - return NULL; - - TAILQ_FOREACH(pipeline, &obj->pipeline_list, node) - if (strcmp(name, pipeline->name) == 0) - return pipeline; - - return NULL; -} - /* * obj */ @@ -587,7 +521,6 @@ obj_init(void) TAILQ_INIT(&obj->mempool_list); TAILQ_INIT(&obj->link_list); TAILQ_INIT(&obj->ring_list); - TAILQ_INIT(&obj->pipeline_list); TAILQ_INIT(&obj->tap_list); return obj; diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index b921610554..e63a9c0e9a 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -143,28 +143,4 @@ tap_next(struct obj *obj, struct tap *tap); struct tap * tap_create(struct obj *obj, const char *name); -/* - * pipeline - */ -struct pipeline { - TAILQ_ENTRY(pipeline) node; - char name[NAME_SIZE]; - - struct rte_swx_pipeline *p; - struct rte_swx_ctl_pipeline *ctl; - - uint32_t timer_period_ms; - int enabled; - uint32_t thread_id; - uint32_t cpu_id; -}; - -struct pipeline * -pipeline_create(struct obj *obj, - const char *name, - int numa_node); - -struct pipeline * -pipeline_find(struct obj *obj, const char *name); - #endif /* _INCLUDE_OBJ_H_ */ diff --git a/examples/pipeline/thread.c b/examples/pipeline/thread.c index 5fe7eae00e..6d15f51fb2 100644 --- a/examples/pipeline/thread.c +++ b/examples/pipeline/thread.c @@ -228,20 +228,33 @@ thread_msg_send_recv(uint32_t thread_id, return rsp; } +static int +thread_is_pipeline_enabled(uint32_t thread_id, struct rte_swx_pipeline *p) +{ + struct thread *t = &thread[thread_id]; + struct thread_data *td = &thread_data[thread_id]; + uint32_t i; + + if (!t->enabled) + return 0; /* Pipeline NOT enabled on this thread. */ + + for (i = 0; i < td->n_pipelines; i++) + if (td->p[i] == p) + return 1; /* Pipeline enabled on this thread. */ + + return 0 /* Pipeline NOT enabled on this thread. */; +} + int -thread_pipeline_enable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name) +thread_pipeline_enable(uint32_t thread_id, struct rte_swx_pipeline *p, uint32_t timer_period_ms) { - struct pipeline *p = pipeline_find(obj, pipeline_name); struct thread *t; struct thread_msg_req *req; struct thread_msg_rsp *rsp; int status; /* Check input params */ - if ((thread_id >= RTE_MAX_LCORE) || - (p == NULL)) + if ((thread_id >= RTE_MAX_LCORE) || !p || !timer_period_ms) return -1; t = &thread[thread_id]; @@ -256,19 +269,14 @@ thread_pipeline_enable(uint32_t thread_id, return -1; /* Data plane thread */ - td->p[td->n_pipelines] = p->p; + td->p[td->n_pipelines] = p; - tdp->p = p->p; - tdp->timer_period = - (rte_get_tsc_hz() * p->timer_period_ms) / 1000; + tdp->p = p; + tdp->timer_period = (rte_get_tsc_hz() * timer_period_ms) / 1000; tdp->time_next = rte_get_tsc_cycles() + tdp->timer_period; td->n_pipelines++; - /* Pipeline */ - p->thread_id = thread_id; - p->enabled = 1; - return 0; } @@ -279,8 +287,8 @@ thread_pipeline_enable(uint32_t thread_id, /* Write request */ req->type = THREAD_REQ_PIPELINE_ENABLE; - req->pipeline_enable.p = p->p; - req->pipeline_enable.timer_period_ms = p->timer_period_ms; + req->pipeline_enable.p = p; + req->pipeline_enable.timer_period_ms = timer_period_ms; /* Send request and wait for response */ rsp = thread_msg_send_recv(thread_id, req); @@ -295,38 +303,28 @@ thread_pipeline_enable(uint32_t thread_id, if (status) return status; - p->thread_id = thread_id; - p->enabled = 1; - return 0; } int -thread_pipeline_disable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name) +thread_pipeline_disable(uint32_t thread_id, struct rte_swx_pipeline *p) { - struct pipeline *p = pipeline_find(obj, pipeline_name); struct thread *t; struct thread_msg_req *req; struct thread_msg_rsp *rsp; int status; /* Check input params */ - if ((thread_id >= RTE_MAX_LCORE) || - (p == NULL)) + if ((thread_id >= RTE_MAX_LCORE) || !p) return -1; t = &thread[thread_id]; if (t->enabled == 0) return -1; - if (p->enabled == 0) + if (!thread_is_pipeline_enabled(thread_id, p)) return 0; - if (p->thread_id != thread_id) - return -1; - if (!thread_is_running(thread_id)) { struct thread_data *td = &thread_data[thread_id]; uint32_t i; @@ -334,7 +332,7 @@ thread_pipeline_disable(uint32_t thread_id, for (i = 0; i < td->n_pipelines; i++) { struct pipeline_data *tdp = &td->pipeline_data[i]; - if (tdp->p != p->p) + if (tdp->p != p) continue; /* Data plane thread */ @@ -350,9 +348,6 @@ thread_pipeline_disable(uint32_t thread_id, td->n_pipelines--; - /* Pipeline */ - p->enabled = 0; - break; } @@ -366,7 +361,7 @@ thread_pipeline_disable(uint32_t thread_id, /* Write request */ req->type = THREAD_REQ_PIPELINE_DISABLE; - req->pipeline_disable.p = p->p; + req->pipeline_disable.p = p; /* Send request and wait for response */ rsp = thread_msg_send_recv(thread_id, req); @@ -381,8 +376,6 @@ thread_pipeline_disable(uint32_t thread_id, if (status) return status; - p->enabled = 0; - return 0; } diff --git a/examples/pipeline/thread.h b/examples/pipeline/thread.h index d9d8645d4c..712cb25bbb 100644 --- a/examples/pipeline/thread.h +++ b/examples/pipeline/thread.h @@ -7,17 +7,16 @@ #include -#include "obj.h" +#include int thread_pipeline_enable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name); + struct rte_swx_pipeline *p, + uint32_t timer_period_ms); int thread_pipeline_disable(uint32_t thread_id, - struct obj *obj, - const char *pipeline_name); + struct rte_swx_pipeline *p); int thread_init(void); From patchwork Wed Jul 27 23:01:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114327 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 08D30A00C4; Thu, 28 Jul 2022 01:03:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35B0542BE8; Thu, 28 Jul 2022 01:01:56 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 2CFDA42BD9 for ; Thu, 28 Jul 2022 01:01:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962911; x=1690498911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmDg1AR982LIltOn9SqBqacO17+vmGA8gmgWNPsCCAk=; b=UJxDx6W0WtFwGkA1bvwm6G6oIw/zyzMmhU4er/q4kzEp5vaOz0Y6t0Y+ xejA0lrMFuE+s6V7NOcL086Kp/BDINmL8rU9+j2bF+bNHafYB8uxO+qqf nh/jg28tMCl70ieM6WR0lDsStWi0MTd2bKcxh3LBtPzflMR5WyJUOA7Od aopa00w8iRez1e/3qGj6shXTOMGKMzc7MLvUfMZPL725RpNEQRHH6irxJ 5noBuCNIIHrydnI8oQgleN7gEpUIcjTQGRuLIpZ5kb0TjubaSHcg4tzem ZFDMimrgo/mYzTEmog+iazoLBpvv5MDuaqWNKl7iMJE0ZbsR9tJDGS43u Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135841" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135841" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444404" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:48 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 15/17] examples/pipeline: rework the link CLI command Date: Wed, 27 Jul 2022 23:01:30 +0000 Message-Id: <20220727230132.601114-15-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 link CLI command for better alignment with the naming conventions used in the pipeline I/O specification file. Use the library linked list of devices and remove the application list. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 81 +++++++++++++---------------------------- examples/pipeline/obj.c | 16 ++------ examples/pipeline/obj.h | 4 -- 3 files changed, 29 insertions(+), 72 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index f48ff326be..d56a830fb7 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -106,22 +106,6 @@ parser_read_uint32(uint32_t *value, const char *p) return 0; } -static int -parser_read_uint16(uint16_t *value, const char *p) -{ - uint64_t val = 0; - int ret = parser_read_uint64(&val, p); - - if (ret < 0) - return ret; - - if (val > UINT16_MAX) - return -ERANGE; - - *value = val; - return 0; -} - #define PARSE_DELIMITER " \f\n\r\t\v" static int @@ -230,16 +214,15 @@ cmd_mempool(char **tokens, } } -static const char cmd_link_help[] = -"link \n" -" dev | port \n" +static const char cmd_ethdev_help[] = +"ethdev \n" " rxq \n" " txq \n" " promiscuous on | off\n" " [rss ... ]\n"; static void -cmd_link(char **tokens, +cmd_ethdev(char **tokens, uint32_t n_tokens, char *out, size_t out_size, @@ -252,65 +235,51 @@ cmd_link(char **tokens, memset(&p, 0, sizeof(p)); - if ((n_tokens < 13) || (n_tokens > 14 + LINK_RXQ_RSS_MAX)) { + if ((n_tokens < 11) || (n_tokens > 12 + LINK_RXQ_RSS_MAX)) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } name = tokens[1]; - if (strcmp(tokens[2], "dev") == 0) - p.dev_name = tokens[3]; - else if (strcmp(tokens[2], "port") == 0) { - p.dev_name = NULL; - - if (parser_read_uint16(&p.port_id, tokens[3]) != 0) { - snprintf(out, out_size, MSG_ARG_INVALID, "port_id"); - return; - } - } else { - snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dev or port"); - return; - } - - if (strcmp(tokens[4], "rxq") != 0) { + if (strcmp(tokens[2], "rxq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); return; } - if (parser_read_uint32(&p.rx.n_queues, tokens[5]) != 0) { + if (parser_read_uint32(&p.rx.n_queues, tokens[3]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "n_queues"); return; } - if (parser_read_uint32(&p.rx.queue_size, tokens[6]) != 0) { + if (parser_read_uint32(&p.rx.queue_size, tokens[4]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_size"); return; } - p.rx.mempool_name = tokens[7]; + p.rx.mempool_name = tokens[5]; - if (strcmp(tokens[8], "txq") != 0) { + if (strcmp(tokens[6], "txq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq"); return; } - if (parser_read_uint32(&p.tx.n_queues, tokens[9]) != 0) { + if (parser_read_uint32(&p.tx.n_queues, tokens[7]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "n_queues"); return; } - if (parser_read_uint32(&p.tx.queue_size, tokens[10]) != 0) { + if (parser_read_uint32(&p.tx.queue_size, tokens[8]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_size"); return; } - if (strcmp(tokens[11], "promiscuous") != 0) { + if (strcmp(tokens[9], "promiscuous") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "promiscuous"); return; } - if (strcmp(tokens[12], "on") == 0) + if (strcmp(tokens[10], "on") == 0) p.promiscuous = 1; - else if (strcmp(tokens[12], "off") == 0) + else if (strcmp(tokens[10], "off") == 0) p.promiscuous = 0; else { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "on or off"); @@ -319,10 +288,10 @@ cmd_link(char **tokens, /* RSS */ p.rx.rss = NULL; - if (n_tokens > 13) { + if (n_tokens > 11) { uint32_t queue_id, i; - if (strcmp(tokens[13], "rss") != 0) { + if (strcmp(tokens[11], "rss") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rss"); return; } @@ -330,7 +299,7 @@ cmd_link(char **tokens, p.rx.rss = &rss; rss.n_queues = 0; - for (i = 14; i < n_tokens; i++) { + for (i = 12; i < n_tokens; i++) { if (parser_read_uint32(&queue_id, tokens[i]) != 0) { snprintf(out, out_size, MSG_ARG_INVALID, "queue_id"); @@ -406,10 +375,10 @@ print_link_info(struct link *link, char *out, size_t out_size) } /* - * link show [] + * ethdev show [] */ static void -cmd_link_show(char **tokens, +cmd_ethdev_show(char **tokens, uint32_t n_tokens, char *out, size_t out_size, @@ -2675,7 +2644,7 @@ cmd_help(char **tokens, "Type 'help ' for command details.\n\n" "List of commands:\n" "\tmempool\n" - "\tlink\n" + "\tethdev\n" "\ttap\n" "\tpipeline codegen\n" "\tpipeline libbuild\n" @@ -2711,8 +2680,8 @@ cmd_help(char **tokens, return; } - if (strcmp(tokens[0], "link") == 0) { - snprintf(out, out_size, "\n%s\n", cmd_link_help); + if (strcmp(tokens[0], "ethdev") == 0) { + snprintf(out, out_size, "\n%s\n", cmd_ethdev_help); return; } @@ -2966,13 +2935,13 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } - if (strcmp(tokens[0], "link") == 0) { + if (strcmp(tokens[0], "ethdev") == 0) { if ((n_tokens >= 2) && (strcmp(tokens[1], "show") == 0)) { - cmd_link_show(tokens, n_tokens, out, out_size, obj); + cmd_ethdev_show(tokens, n_tokens, out, out_size, obj); return; } - cmd_link(tokens, n_tokens, out, out_size, obj); + cmd_ethdev(tokens, n_tokens, out, out_size, obj); return; } diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index d1f519180e..950ab831fb 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -181,7 +181,7 @@ link_create(struct obj *obj, const char *name, struct link_params *params) struct mempool *mempool; uint32_t cpu_id, i; int status; - uint16_t port_id; + uint16_t port_id = 0; /* Check input params */ if ((name == NULL) || @@ -193,16 +193,9 @@ link_create(struct obj *obj, const char *name, struct link_params *params) (params->tx.queue_size == 0)) return NULL; - port_id = params->port_id; - if (params->dev_name) { - status = rte_eth_dev_get_port_by_name(params->dev_name, - &port_id); - - if (status) - return NULL; - } else - if (!rte_eth_dev_is_valid_port(port_id)) - return NULL; + status = rte_eth_dev_get_port_by_name(name, &port_id); + if (status) + return NULL; if (rte_eth_dev_info_get(port_id, &port_info) != 0) return NULL; @@ -315,7 +308,6 @@ link_create(struct obj *obj, const char *name, struct link_params *params) /* Node fill in */ strlcpy(link->name, name, sizeof(link->name)); link->port_id = port_id; - rte_eth_dev_get_name_by_port(port_id, link->dev_name); link->n_rxq = params->rx.n_queues; link->n_txq = params->tx.n_queues; diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index e63a9c0e9a..af270a8e57 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -63,9 +63,6 @@ struct link_params_rss { }; struct link_params { - const char *dev_name; - uint16_t port_id; /**< Valid only when *dev_name* is NULL. */ - struct { uint32_t n_queues; uint32_t queue_size; @@ -84,7 +81,6 @@ struct link_params { struct link { TAILQ_ENTRY(link) node; char name[NAME_SIZE]; - char dev_name[NAME_SIZE]; uint16_t port_id; uint32_t n_rxq; uint32_t n_txq; From patchwork Wed Jul 27 23:01:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114328 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 EC809A00C4; Thu, 28 Jul 2022 01:03:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC1C042BEF; Thu, 28 Jul 2022 01:01:59 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 8999F42BDA for ; Thu, 28 Jul 2022 01:01:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962911; x=1690498911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uZX8+4QfKLcqTrRryvdWz4IJDULmCR6po14r0NtwhbI=; b=bjGzQDrCnEypueqcww+0699xzekXNvJKYejETqgOik+F3rB8gDLmNG0w CIHpmtt94xPrBZGE/8IsDQNqLZuzNtD8lReJ5JbavYVmgxPvOMea9Z7YP wqb2ni9RUIwuQ+Jh5N/9qAjNY0cgtRQHf+aik3+ezNrYOTF3dP5iGPNrd frMayinwDiYr8w79+Ti6tCGtonTST5IhSpJt9Ds9+TtB8XwGxPPyDjRre iY5lhfgOYMC7p/mDeyPZd5MVQMMuYyav576FjcVZO+Jn7VOfuXZAVAyqq VIf5UomYEWtvQpVyCIM0hmOEr1xecFhsyC3zsIp3+b0ksjPoecDdXbL7m g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135847" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135847" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444407" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:49 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 16/17] examples/pipelines: remove obsolete tap CLI command Date: Wed, 27 Jul 2022 23:01:31 +0000 Message-Id: <20220727230132.601114-16-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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 Remove the tap CLI command, as the file descriptor I/O ports of the pipeline are now configured trough the I/O specification file. Signed-off-by: Cristian Dumitrescu Signed-off-by: Kamalakannan R. --- examples/pipeline/cli.c | 37 ----------------- examples/pipeline/obj.c | 89 ----------------------------------------- examples/pipeline/obj.h | 18 --------- 3 files changed, 144 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index d56a830fb7..75c32b9089 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -466,32 +466,6 @@ cmd_ring(char **tokens, } } -static const char cmd_tap_help[] = -"tap \n"; - -static void -cmd_tap(char **tokens, - uint32_t n_tokens, - char *out, - size_t out_size, - void *obj) -{ - struct tap *tap; - char *name; - - if (n_tokens < 2) { - snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); - return; - } - name = tokens[1]; - - tap = tap_create(obj, name); - if (tap == NULL) { - snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); - return; - } -} - static const char cmd_pipeline_codegen_help[] = "pipeline codegen \n"; @@ -2645,7 +2619,6 @@ cmd_help(char **tokens, "List of commands:\n" "\tmempool\n" "\tethdev\n" - "\ttap\n" "\tpipeline codegen\n" "\tpipeline libbuild\n" "\tpipeline build\n" @@ -2690,11 +2663,6 @@ cmd_help(char **tokens, return; } - if (strcmp(tokens[0], "tap") == 0) { - snprintf(out, out_size, "\n%s\n", cmd_tap_help); - return; - } - 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); @@ -2950,11 +2918,6 @@ cli_process(char *in, char *out, size_t out_size, void *obj) return; } - if (strcmp(tokens[0], "tap") == 0) { - cmd_tap(tokens, n_tokens, out, out_size, obj); - return; - } - if (strcmp(tokens[0], "pipeline") == 0) { if ((n_tokens >= 3) && (strcmp(tokens[1], "codegen") == 0)) { diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index 950ab831fb..b7e2316eec 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -35,11 +35,6 @@ TAILQ_HEAD(link_list, link); */ TAILQ_HEAD(ring_list, ring); -/* - * tap - */ -TAILQ_HEAD(tap_list, tap); - /* * obj */ @@ -47,7 +42,6 @@ struct obj { struct mempool_list mempool_list; struct link_list link_list; struct ring_list ring_list; - struct tap_list tap_list; }; /* @@ -416,88 +410,6 @@ ring_find(struct obj *obj, const char *name) return NULL; } -/* - * tap - */ -#define TAP_DEV "/dev/net/tun" - -struct tap * -tap_find(struct obj *obj, const char *name) -{ - struct tap *tap; - - if (!obj || !name) - return NULL; - - TAILQ_FOREACH(tap, &obj->tap_list, node) - if (strcmp(tap->name, name) == 0) - return tap; - - return NULL; -} - -struct tap * -tap_next(struct obj *obj, struct tap *tap) -{ - return (tap == NULL) ? - TAILQ_FIRST(&obj->tap_list) : TAILQ_NEXT(tap, node); -} - -#ifndef RTE_EXEC_ENV_LINUX - -struct tap * -tap_create(struct obj *obj __rte_unused, const char *name __rte_unused) -{ - return NULL; -} - -#else - -struct tap * -tap_create(struct obj *obj, const char *name) -{ - struct tap *tap; - struct ifreq ifr; - int fd, status; - - /* Check input params */ - if ((name == NULL) || - tap_find(obj, name)) - return NULL; - - /* Resource create */ - fd = open(TAP_DEV, O_RDWR | O_NONBLOCK); - if (fd < 0) - return NULL; - - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */ - strlcpy(ifr.ifr_name, name, IFNAMSIZ); - - status = ioctl(fd, TUNSETIFF, (void *) &ifr); - if (status < 0) { - close(fd); - return NULL; - } - - /* Node allocation */ - tap = calloc(1, sizeof(struct tap)); - if (tap == NULL) { - close(fd); - return NULL; - } - /* Node fill in */ - strlcpy(tap->name, name, sizeof(tap->name)); - tap->fd = fd; - - /* Node add to list */ - TAILQ_INSERT_TAIL(&obj->tap_list, tap, node); - - return tap; -} - -#endif - /* * obj */ @@ -513,7 +425,6 @@ obj_init(void) TAILQ_INIT(&obj->mempool_list); TAILQ_INIT(&obj->link_list); TAILQ_INIT(&obj->ring_list); - TAILQ_INIT(&obj->tap_list); return obj; } diff --git a/examples/pipeline/obj.h b/examples/pipeline/obj.h index af270a8e57..8ea1c414c2 100644 --- a/examples/pipeline/obj.h +++ b/examples/pipeline/obj.h @@ -121,22 +121,4 @@ ring_create(struct obj *obj, struct ring * ring_find(struct obj *obj, const char *name); -/* - * tap - */ -struct tap { - TAILQ_ENTRY(tap) node; - char name[NAME_SIZE]; - int fd; -}; - -struct tap * -tap_find(struct obj *obj, const char *name); - -struct tap * -tap_next(struct obj *obj, struct tap *tap); - -struct tap * -tap_create(struct obj *obj, const char *name); - #endif /* _INCLUDE_OBJ_H_ */ From patchwork Wed Jul 27 23:01:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 114329 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 89FE9A00C4; Thu, 28 Jul 2022 01:03:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B3BC42BF3; Thu, 28 Jul 2022 01:02:00 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 0251C42B81 for ; Thu, 28 Jul 2022 01:01:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658962912; x=1690498912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o4Hv29nJvXbm18Jgb9+CWzggR1QJ4e4cPLOPwngu8bs=; b=CHEi7cwywL3qyYUmr7BCUWan1HimMDKUHEdmaDo2MtI9GjJOor8BDfPZ 2rZR/DWmkMPh8gJQgZJ4p9TkRdWORkec9g1K2Nk8RlrLLlRV7vEV6CbXE IG51zAyCMO5p/CN1uSmejfvbkw3odeLlb5BC270kqbcitVUUhaCJFyIx5 uXxQ6gD7YNIvP2N2LaAPb9jyex3EOu1hWIxYnKtiGXJRl7ldKgGvyMpr/ TB5hIsRqUZnJgQWvTbukFmVttXcOB8s7PsuPVdOwsRCXy0XkHCYFeLafU WBzaJGkaO5IfT68lzyatUQOtrEZUoxt/ShTwSPxEWNDqv/TR5X52zVSir g==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="289135848" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="289135848" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2022 16:01:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="846444412" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga006.fm.intel.com with ESMTP; 27 Jul 2022 16:01:50 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: "Kamalakannan R ." Subject: [PATCH V5 17/17] examples/pipeline: call the code generation and build CLI commands Date: Wed, 27 Jul 2022 23:01:32 +0000 Message-Id: <20220727230132.601114-17-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727230132.601114-1-cristian.dumitrescu@intel.com> References: <20220727225431.600913-1-cristian.dumitrescu@intel.com> <20220727230132.601114-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/ethdev.io | 27 +++++++++ examples/pipeline/examples/fib.cli | 44 +++++++------- examples/pipeline/examples/hash_func.cli | 41 ++++++------- examples/pipeline/examples/l2fwd.cli | 44 ++++++++------ examples/pipeline/examples/l2fwd_macswp.cli | 44 ++++++++------ .../pipeline/examples/l2fwd_macswp_pcap.cli | 35 +++++++---- examples/pipeline/examples/l2fwd_pcap.cli | 35 +++++++---- examples/pipeline/examples/learner.cli | 43 +++++++------- examples/pipeline/examples/meter.cli | 58 +++++++++++-------- examples/pipeline/examples/mirroring.cli | 46 ++++++++------- examples/pipeline/examples/pcap.io | 27 +++++++++ examples/pipeline/examples/recirculation.cli | 41 ++++++------- examples/pipeline/examples/registers.cli | 53 +++++++++-------- examples/pipeline/examples/selector.cli | 55 +++++++++++------- examples/pipeline/examples/varbit.cli | 41 ++++++------- examples/pipeline/examples/vxlan.cli | 48 ++++++++++----- examples/pipeline/examples/vxlan_pcap.cli | 39 +++++++++---- 17 files changed, 444 insertions(+), 277 deletions(-) create mode 100644 examples/pipeline/examples/ethdev.io create mode 100644 examples/pipeline/examples/pcap.io diff --git a/examples/pipeline/examples/ethdev.io b/examples/pipeline/examples/ethdev.io new file mode 100644 index 0000000000..cf2f3e20bd --- /dev/null +++ b/examples/pipeline/examples/ethdev.io @@ -0,0 +1,27 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2022 Intel Corporation + +; +; Pipeline packet mirroring. +; +mirroring slots 4 sessions 64 + +; +; Pipeline input ports. +; +; Note: Customize the parameters below to match your setup. +; +port in 0 ethdev 0000:18:00.0 rxq 0 bsz 32 +port in 1 ethdev 0000:18:00.1 rxq 0 bsz 32 +port in 2 ethdev 0000:3b:00.0 rxq 0 bsz 32 +port in 3 ethdev 0000:3b:00.1 rxq 0 bsz 32 + +; +; Pipeline output ports. +; +; Note: Customize the parameters below to match your setup. +; +port out 0 ethdev 0000:18:00.0 txq 0 bsz 32 +port out 1 ethdev 0000:18:00.1 txq 0 bsz 32 +port out 2 ethdev 0000:3b:00.0 txq 0 bsz 32 +port out 3 ethdev 0000:3b:00.1 txq 0 bsz 32 diff --git a/examples/pipeline/examples/fib.cli b/examples/pipeline/examples/fib.cli index 93ab2b08f8..4e30c1320f 100644 --- a/examples/pipeline/examples/fib.cli +++ b/examples/pipeline/examples/fib.cli @@ -1,38 +1,38 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/fib.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/fib.spec /tmp/fib.c +pipeline libbuild /tmp/fib.c /tmp/fib.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/fib.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/fib.so io ./examples/pipeline/examples/ethdev.io numa 0 ; ; Initial set of table entries. ; -; The table entries can later be updated at run-time through the CLI commands. Once the application -; has been successfully started, the command to get the CLI prompt is: telnet 0.0.0.0 8086. +; The table entries can later be updated at run-time through the CLI commands. ; pipeline PIPELINE0 table routing_table add ./examples/pipeline/examples/fib_routing_table.txt pipeline PIPELINE0 selector nexthop_group_table group add diff --git a/examples/pipeline/examples/hash_func.cli b/examples/pipeline/examples/hash_func.cli index d65cd62d17..b2e219e4c9 100644 --- a/examples/pipeline/examples/hash_func.cli +++ b/examples/pipeline/examples/hash_func.cli @@ -1,32 +1,33 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/hash_func.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/hash_func.spec /tmp/hash_func.c +pipeline libbuild /tmp/hash_func.c /tmp/hash_func.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/hash_func.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/hash_func.so io ./examples/pipeline/examples/ethdev.io numa 0 ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/l2fwd.cli b/examples/pipeline/examples/l2fwd.cli index d89caf2d0a..27e37021b9 100644 --- a/examples/pipeline/examples/l2fwd.cli +++ b/examples/pipeline/examples/l2fwd.cli @@ -1,25 +1,35 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/l2fwd.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 create 0 +; +; 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 -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/l2fwd.so io ./examples/pipeline/examples/ethdev.io numa 0 +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/l2fwd_macswp.cli b/examples/pipeline/examples/l2fwd_macswp.cli index 0f2a89ac5b..11bb4543b9 100644 --- a/examples/pipeline/examples/l2fwd_macswp.cli +++ b/examples/pipeline/examples/l2fwd_macswp.cli @@ -1,25 +1,35 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/l2fwd_macswp.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 create 0 +; +; 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 -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd_macswp.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/l2fwd_macswp.so io ./examples/pipeline/examples/ethdev.io numa 0 +; +; Pipelines-to-threads mapping. +; 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..8724dae3b0 100644 --- a/examples/pipeline/examples/l2fwd_macswp_pcap.cli +++ b/examples/pipeline/examples/l2fwd_macswp_pcap.cli @@ -1,20 +1,31 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 - -pipeline PIPELINE0 create 0 +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/l2fwd_macswp_pcap.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 +; +; 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 -pipeline PIPELINE0 port out 0 sink none -pipeline PIPELINE0 port out 1 sink none -pipeline PIPELINE0 port out 2 sink none -pipeline PIPELINE0 port out 3 sink none +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd_macswp.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/l2fwd_macswp.so io ./examples/pipeline/examples/pcap.io numa 0 +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/l2fwd_pcap.cli b/examples/pipeline/examples/l2fwd_pcap.cli index 23fcb199f1..4db0a0dc56 100644 --- a/examples/pipeline/examples/l2fwd_pcap.cli +++ b/examples/pipeline/examples/l2fwd_pcap.cli @@ -1,20 +1,31 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 - -pipeline PIPELINE0 create 0 +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/l2fwd_pcap.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 +; +; 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 -pipeline PIPELINE0 port out 0 sink none -pipeline PIPELINE0 port out 1 sink none -pipeline PIPELINE0 port out 2 sink none -pipeline PIPELINE0 port out 3 sink none +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 -pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/l2fwd.so io ./examples/pipeline/examples/pcap.io numa 0 +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/learner.cli b/examples/pipeline/examples/learner.cli index 688ce34f34..6c8aa3921e 100644 --- a/examples/pipeline/examples/learner.cli +++ b/examples/pipeline/examples/learner.cli @@ -1,36 +1,35 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/learner.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/learner.spec /tmp/learner.c +pipeline libbuild /tmp/learner.c /tmp/learner.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/learner.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/learner.so io ./examples/pipeline/examples/ethdev.io numa 0 ; ; Pipelines-to-threads mapping. ; thread 1 pipeline PIPELINE0 enable - -; Once the application has started, the command to get the CLI prompt is: telnet 0.0.0.0 8086 diff --git a/examples/pipeline/examples/meter.cli b/examples/pipeline/examples/meter.cli index b29ed24022..c1b88c882a 100644 --- a/examples/pipeline/examples/meter.cli +++ b/examples/pipeline/examples/meter.cli @@ -1,31 +1,43 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -; Example command line: -; ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/meter.cli - +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/meter.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + +; +; 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 + +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; 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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on - -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 - +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on + +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/meter.so io ./examples/pipeline/examples/ethdev.io numa 0 + +; +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. +; 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 +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/mirroring.cli b/examples/pipeline/examples/mirroring.cli index 46d57db4ec..1d439e04d3 100644 --- a/examples/pipeline/examples/mirroring.cli +++ b/examples/pipeline/examples/mirroring.cli @@ -1,36 +1,38 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/mirroring.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/mirroring.spec /tmp/mirroring.c +pipeline libbuild /tmp/mirroring.c /tmp/mirroring.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 -pipeline PIPELINE0 mirror slots 4 sessions 16 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/mirroring.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/mirroring.so io ./examples/pipeline/examples/ethdev.io numa 0 ; -; Packet mirroring sessions. +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. ; pipeline PIPELINE0 mirror session 0 port 1 clone fast truncate 0 pipeline PIPELINE0 mirror session 1 port 2 clone slow truncate 0 diff --git a/examples/pipeline/examples/pcap.io b/examples/pipeline/examples/pcap.io new file mode 100644 index 0000000000..111f61afae --- /dev/null +++ b/examples/pipeline/examples/pcap.io @@ -0,0 +1,27 @@ +; SPDX-License-Identifier: BSD-3-Clause +; Copyright(c) 2022 Intel Corporation + +; +; Pipeline packet mirroring. +; +mirroring slots 4 sessions 64 + +; +; Pipeline input ports. +; +; Note: Customize the parameters below to match your setup. +; +port in 0 source mempool MEMPOOL0 file ./examples/pipeline/examples/packet.pcap loop 1 packets 0 +port in 1 source mempool MEMPOOL0 file ./examples/pipeline/examples/packet.pcap loop 1 packets 0 +port in 2 source mempool MEMPOOL0 file ./examples/pipeline/examples/packet.pcap loop 1 packets 0 +port in 3 source mempool MEMPOOL0 file ./examples/pipeline/examples/packet.pcap loop 1 packets 0 + +; +; Pipeline output ports. +; +; Note: Customize the parameters below to match your setup. +; +port out 0 sink file none +port out 1 sink file none +port out 2 sink file none +port out 3 sink file none diff --git a/examples/pipeline/examples/recirculation.cli b/examples/pipeline/examples/recirculation.cli index f855c5c327..52d0894f12 100644 --- a/examples/pipeline/examples/recirculation.cli +++ b/examples/pipeline/examples/recirculation.cli @@ -1,32 +1,33 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2022 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/recirculation.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/recirculation.spec /tmp/recirculation.c +pipeline libbuild /tmp/recirculation.c /tmp/recirculation.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/recirculation.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/recirculation.so io ./examples/pipeline/examples/ethdev.io numa 0 ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/registers.cli b/examples/pipeline/examples/registers.cli index 8d026294cb..3516f76a5b 100644 --- a/examples/pipeline/examples/registers.cli +++ b/examples/pipeline/examples/registers.cli @@ -1,28 +1,35 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -; Example command line: -; ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/registers.cli - +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/registers.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + +; +; 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 + +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; 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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on - -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 - +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on + +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/registers.so io ./examples/pipeline/examples/ethdev.io numa 0 + +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/selector.cli b/examples/pipeline/examples/selector.cli index 123782c57b..f0e251b657 100644 --- a/examples/pipeline/examples/selector.cli +++ b/examples/pipeline/examples/selector.cli @@ -1,30 +1,45 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/selector.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + +; +; 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 + +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; 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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on - -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 - +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on + +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/selector.so io ./examples/pipeline/examples/ethdev.io numa 0 + +; +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. +; pipeline PIPELINE0 selector s group add pipeline PIPELINE0 selector s group member add ./examples/pipeline/examples/selector.txt pipeline PIPELINE0 commit pipeline PIPELINE0 selector s show +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/varbit.cli b/examples/pipeline/examples/varbit.cli index 9caeb9ca26..0f89990471 100644 --- a/examples/pipeline/examples/varbit.cli +++ b/examples/pipeline/examples/varbit.cli @@ -1,32 +1,33 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/varbit.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 + ; -; Customize the LINK parameters to match your setup. +; Pipeline code generation & shared object library build. ; -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +pipeline codegen ./examples/pipeline/examples/varbit.spec /tmp/varbit.c +pipeline libbuild /tmp/varbit.c /tmp/varbit.so ; -; PIPELINE0 setup. +; List of DPDK devices. ; -pipeline PIPELINE0 create 0 - -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 - -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 build ./examples/pipeline/examples/varbit.spec +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/varbit.so io ./examples/pipeline/examples/ethdev.io numa 0 ; ; Pipelines-to-threads mapping. diff --git a/examples/pipeline/examples/vxlan.cli b/examples/pipeline/examples/vxlan.cli index 444f3f7bd8..1fbd1be6e4 100644 --- a/examples/pipeline/examples/vxlan.cli +++ b/examples/pipeline/examples/vxlan.cli @@ -1,27 +1,43 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -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 -link LINK1 dev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK2 dev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -link LINK3 dev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/vxlan.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 create 0 +; +; 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 -pipeline PIPELINE0 port in 0 link LINK0 rxq 0 bsz 32 -pipeline PIPELINE0 port in 1 link LINK1 rxq 0 bsz 32 -pipeline PIPELINE0 port in 2 link LINK2 rxq 0 bsz 32 -pipeline PIPELINE0 port in 3 link LINK3 rxq 0 bsz 32 +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on +ethdev 0000:3b:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on -pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32 -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 +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/vxlan.so io ./examples/pipeline/examples/ethdev.io numa 0 -pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec +; +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. +; pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt pipeline PIPELINE0 commit +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable diff --git a/examples/pipeline/examples/vxlan_pcap.cli b/examples/pipeline/examples/vxlan_pcap.cli index 83fca8d0d9..adc7f73312 100644 --- a/examples/pipeline/examples/vxlan_pcap.cli +++ b/examples/pipeline/examples/vxlan_pcap.cli @@ -1,22 +1,39 @@ ; SPDX-License-Identifier: BSD-3-Clause ; Copyright(c) 2020 Intel Corporation -mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 +# Example command line: +# ./build/examples/dpdk-pipeline -l0-1 -- -s ./examples/pipeline/examples/vxlan_pcap.cli +# +# Once the application has started, the command to get the CLI prompt is: +# telnet 0.0.0.0 8086 -pipeline PIPELINE0 create 0 +; +; 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 -pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 -pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1 +; +; List of DPDK devices. +; +; Note: Customize the parameters below to match your setup. +; +mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0 -pipeline PIPELINE0 port out 0 sink none -pipeline PIPELINE0 port out 1 sink none -pipeline PIPELINE0 port out 2 sink none -pipeline PIPELINE0 port out 3 sink none +; +; List of pipelines. +; +pipeline PIPELINE0 build lib /tmp/vxlan.so io ./examples/pipeline/examples/pcap.io numa 0 -pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec +; +; Initial set of table entries. +; +; The table entries can later be updated at run-time through the CLI commands. +; pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt pipeline PIPELINE0 commit +; +; Pipelines-to-threads mapping. +; thread 1 pipeline PIPELINE0 enable