From patchwork Sat Nov 27 00:02:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 104723 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 2CDCCA0C43; Sat, 27 Nov 2021 01:03:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 069D342749; Sat, 27 Nov 2021 01:03:00 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 255C34068A for ; Sat, 27 Nov 2021 01:02:57 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10180"; a="215751234" X-IronPort-AV: E=Sophos;i="5.87,267,1631602800"; d="scan'208";a="215751234" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2021 16:02:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,267,1631602800"; d="scan'208";a="652292974" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga001.fm.intel.com with ESMTP; 26 Nov 2021 16:02:56 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: yogesh.jangra@intel.com Subject: [PATCH V2 2/4] pipeline: move port type registration to library Date: Sat, 27 Nov 2021 00:02:52 +0000 Message-Id: <20211127000254.36148-2-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211127000254.36148-1-cristian.dumitrescu@intel.com> References: <20211126235129.35781-1-cristian.dumitrescu@intel.com> <20211127000254.36148-1-cristian.dumitrescu@intel.com> 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 the port type registration for the well known port types from the application to the pipeline library. Signed-off-by: Cristian Dumitrescu Signed-off-by: Yogesh Jangra --- examples/pipeline/obj.c | 54 ----------- lib/pipeline/rte_swx_pipeline.c | 159 ++++++++++++++++++++++++-------- 2 files changed, 123 insertions(+), 90 deletions(-) diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c index 569207a79d..4b2db66c46 100644 --- a/examples/pipeline/obj.c +++ b/examples/pipeline/obj.c @@ -16,10 +16,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -543,56 +539,6 @@ pipeline_create(struct obj *obj, const char *name, int numa_node) if (status) goto error; - status = rte_swx_pipeline_port_in_type_register(p, - "ethdev", - &rte_swx_port_ethdev_reader_ops); - if (status) - goto error; - - status = rte_swx_pipeline_port_out_type_register(p, - "ethdev", - &rte_swx_port_ethdev_writer_ops); - if (status) - goto error; - - status = rte_swx_pipeline_port_in_type_register(p, - "ring", - &rte_swx_port_ring_reader_ops); - if (status) - goto error; - - status = rte_swx_pipeline_port_out_type_register(p, - "ring", - &rte_swx_port_ring_writer_ops); - if (status) - goto error; - -#ifdef RTE_PORT_PCAP - status = rte_swx_pipeline_port_in_type_register(p, - "source", - &rte_swx_port_source_ops); - if (status) - goto error; -#endif - - status = rte_swx_pipeline_port_out_type_register(p, - "sink", - &rte_swx_port_sink_ops); - if (status) - goto error; - - status = rte_swx_pipeline_port_in_type_register(p, - "fd", - &rte_swx_port_fd_reader_ops); - if (status) - goto error; - - status = rte_swx_pipeline_port_out_type_register(p, - "fd", - &rte_swx_port_fd_writer_ops); - if (status) - goto error; - status = rte_swx_pipeline_table_type_register(p, "exact", RTE_SWX_TABLE_MATCH_EXACT, diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index ff2fe964a5..bebad98e99 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -7,6 +7,11 @@ #include #include +#include +#include +#include +#include "rte_swx_port_source_sink.h" + #include "rte_swx_pipeline_internal.h" #define CHECK(condition, err_code) \ @@ -8982,17 +8987,122 @@ metarray_free(struct rte_swx_pipeline *p) /* * Pipeline. */ +void +rte_swx_pipeline_free(struct rte_swx_pipeline *p) +{ + void *lib; + + if (!p) + return; + + lib = p->lib; + + free(p->instruction_data); + free(p->instructions); + + metarray_free(p); + regarray_free(p); + table_state_free(p); + learner_free(p); + selector_free(p); + table_free(p); + action_free(p); + instruction_table_free(p); + metadata_free(p); + header_free(p); + extern_func_free(p); + extern_obj_free(p); + port_out_free(p); + port_in_free(p); + struct_free(p); + + free(p); + + if (lib) + dlclose(lib); +} + +static int +port_in_types_register(struct rte_swx_pipeline *p) +{ + int status; + + status = rte_swx_pipeline_port_in_type_register(p, + "ethdev", + &rte_swx_port_ethdev_reader_ops); + if (status) + return status; + + status = rte_swx_pipeline_port_in_type_register(p, + "ring", + &rte_swx_port_ring_reader_ops); + if (status) + return status; + +#ifdef RTE_PORT_PCAP + status = rte_swx_pipeline_port_in_type_register(p, + "source", + &rte_swx_port_source_ops); + if (status) + return status; +#endif + + status = rte_swx_pipeline_port_in_type_register(p, + "fd", + &rte_swx_port_fd_reader_ops); + if (status) + return status; + + return 0; +} + +static int +port_out_types_register(struct rte_swx_pipeline *p) +{ + int status; + + status = rte_swx_pipeline_port_out_type_register(p, + "ethdev", + &rte_swx_port_ethdev_writer_ops); + if (status) + return status; + + status = rte_swx_pipeline_port_out_type_register(p, + "ring", + &rte_swx_port_ring_writer_ops); + if (status) + return status; + + status = rte_swx_pipeline_port_out_type_register(p, + "sink", + &rte_swx_port_sink_ops); + if (status) + return status; + + status = rte_swx_pipeline_port_out_type_register(p, + "fd", + &rte_swx_port_fd_writer_ops); + if (status) + return status; + + return 0; +} + int rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) { - struct rte_swx_pipeline *pipeline; + struct rte_swx_pipeline *pipeline = NULL; + int status = 0; /* Check input parameters. */ CHECK(p, EINVAL); /* Memory allocation. */ pipeline = calloc(1, sizeof(struct rte_swx_pipeline)); - CHECK(pipeline, ENOMEM); + if (!pipeline) { + status = -ENOMEM; + goto error; + } /* Initialization. */ TAILQ_INIT(&pipeline->struct_types); @@ -9016,43 +9126,20 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node) pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */ pipeline->numa_node = numa_node; - *p = pipeline; - return 0; -} - -void -rte_swx_pipeline_free(struct rte_swx_pipeline *p) -{ - void *lib; - - if (!p) - return; - - lib = p->lib; - - free(p->instruction_data); - free(p->instructions); + status = port_in_types_register(pipeline); + if (status) + goto error; - metarray_free(p); - regarray_free(p); - table_state_free(p); - learner_free(p); - selector_free(p); - table_free(p); - action_free(p); - instruction_table_free(p); - metadata_free(p); - header_free(p); - extern_func_free(p); - extern_obj_free(p); - port_out_free(p); - port_in_free(p); - struct_free(p); + status = port_out_types_register(pipeline); + if (status) + goto error; - free(p); + *p = pipeline; + return 0; - if (lib) - dlclose(lib); +error: + rte_swx_pipeline_free(pipeline); + return status; } int