From patchwork Thu Sep 6 16:26:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 44336 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1BA1356A3; Thu, 6 Sep 2018 18:27:16 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 461AB4F94 for ; Thu, 6 Sep 2018 18:27:12 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 09:27:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,338,1531810800"; d="scan'208";a="68064441" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by fmsmga007.fm.intel.com with ESMTP; 06 Sep 2018 09:27:10 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: Cristian Dumitrescu , Reshma Pattan Date: Thu, 6 Sep 2018 17:26:52 +0100 Message-Id: <1536251222-17275-6-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> References: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH 05/15] net/softnic: add free table and find out port functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added utility function to freeup the pipeline tables. Added utility functions to find the pipeline output port. Signed-off-by: Cristian Dumitrescu Signed-off-by: Reshma Pattan --- drivers/net/softnic/rte_eth_softnic_internals.h | 13 ++++++ drivers/net/softnic/rte_eth_softnic_pipeline.c | 57 +++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index f40215dfe..9c587bc7d 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -415,10 +415,15 @@ struct softnic_port_in { struct rte_port_in_action *a; }; +struct softnic_port_out { + struct softnic_port_out_params params; +}; + struct softnic_table { struct softnic_table_params params; struct softnic_table_action_profile *ap; struct rte_table_action *a; + struct flow_list flows; }; struct pipeline { @@ -426,7 +431,9 @@ struct pipeline { char name[NAME_SIZE]; struct rte_pipeline *p; + struct pipeline_params params; struct softnic_port_in port_in[RTE_PIPELINE_PORT_IN_MAX]; + struct softnic_port_out port_out[RTE_PIPELINE_PORT_OUT_MAX]; struct softnic_table table[RTE_PIPELINE_TABLE_MAX]; uint32_t n_ports_in; uint32_t n_ports_out; @@ -725,6 +732,12 @@ softnic_pipeline_port_out_create(struct pmd_internals *p, const char *pipeline_name, struct softnic_port_out_params *params); +int +softnic_pipeline_port_out_find(struct pmd_internals *softnic, + const char *pipeline_name, + const char *name, + uint32_t *port_id); + int softnic_pipeline_table_create(struct pmd_internals *p, const char *pipeline_name, diff --git a/drivers/net/softnic/rte_eth_softnic_pipeline.c b/drivers/net/softnic/rte_eth_softnic_pipeline.c index dacf7bc9a..d1084ea36 100644 --- a/drivers/net/softnic/rte_eth_softnic_pipeline.c +++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c @@ -43,17 +43,41 @@ softnic_pipeline_init(struct pmd_internals *p) return 0; } +static void +softnic_pipeline_table_free(struct softnic_table *table) +{ + for ( ; ; ) { + struct rte_flow *flow; + + flow = TAILQ_FIRST(&table->flows); + if (flow == NULL) + break; + + TAILQ_REMOVE(&table->flows, flow, node); + free(flow); + } +} + void softnic_pipeline_free(struct pmd_internals *p) { for ( ; ; ) { struct pipeline *pipeline; + uint32_t table_id; pipeline = TAILQ_FIRST(&p->pipeline_list); if (pipeline == NULL) break; TAILQ_REMOVE(&p->pipeline_list, pipeline, node); + + for (table_id = 0; table_id < pipeline->n_tables; table_id++) { + struct softnic_table *table = + &pipeline->table[table_id]; + + softnic_pipeline_table_free(table); + } + rte_ring_free(pipeline->msgq_req); rte_ring_free(pipeline->msgq_rsp); rte_pipeline_free(pipeline->p); @@ -160,6 +184,7 @@ softnic_pipeline_create(struct pmd_internals *softnic, /* Node fill in */ strlcpy(pipeline->name, name, sizeof(pipeline->name)); pipeline->p = p; + memcpy(&pipeline->params, params, sizeof(*params)); pipeline->n_ports_in = 0; pipeline->n_ports_out = 0; pipeline->n_tables = 0; @@ -401,6 +426,7 @@ softnic_pipeline_port_out_create(struct pmd_internals *softnic, } pp_nodrop; struct pipeline *pipeline; + struct softnic_port_out *port_out; uint32_t port_id; int status; @@ -542,6 +568,8 @@ softnic_pipeline_port_out_create(struct pmd_internals *softnic, return -1; /* Pipeline */ + port_out = &pipeline->port_out[pipeline->n_ports_out]; + memcpy(&port_out->params, params, sizeof(*params)); pipeline->n_ports_out++; return 0; @@ -960,7 +988,36 @@ softnic_pipeline_table_create(struct pmd_internals *softnic, memcpy(&table->params, params, sizeof(*params)); table->ap = ap; table->a = action; + TAILQ_INIT(&table->flows); pipeline->n_tables++; return 0; } + +int +softnic_pipeline_port_out_find(struct pmd_internals *softnic, + const char *pipeline_name, + const char *name, + uint32_t *port_id) +{ + struct pipeline *pipeline; + uint32_t i; + + if (softnic == NULL || + pipeline_name == NULL || + name == NULL || + port_id == NULL) + return -1; + + pipeline = softnic_pipeline_find(softnic, pipeline_name); + if (pipeline == NULL) + return -1; + + for (i = 0; i < pipeline->n_ports_out; i++) + if (strcmp(pipeline->port_out[i].params.dev_name, name) == 0) { + *port_id = i; + return 0; + } + + return -1; +}