From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 258034C8E for ; Mon, 8 Oct 2018 13:19:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2018 04:19:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,356,1534834800"; d="scan'208";a="90134125" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by orsmga003.jf.intel.com with ESMTP; 08 Oct 2018 04:19:15 -0700 From: Reshma Pattan To: dev@dpdk.org, cristian.dumitrescu@intel.com, jasvinder.singh@intel.com Cc: Reshma Pattan Date: Mon, 8 Oct 2018 12:19:11 +0100 Message-Id: <1538997551-23635-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1538411914-12721-1-git-send-email-reshma.pattan@intel.com> References: <1538411914-12721-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH v4] net/softnic: add flow flush API 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: , X-List-Received-Date: Mon, 08 Oct 2018 11:19:18 -0000 Add rte flow flush api for flushing all the flows of the port. Signed-off-by: Reshma Pattan --- v4: Abort on rule deletion failures only at the end. v3: Some style related changes v2: Use TAILQ_FOREACH_SAFE instead of TAILQ_FOREACH for safe removal using TAILQ_REMOVAL. --- drivers/net/softnic/rte_eth_softnic_flow.c | 50 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c index 03d41bc01..30aa6af5e 100644 --- a/drivers/net/softnic/rte_eth_softnic_flow.c +++ b/drivers/net/softnic/rte_eth_softnic_flow.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "rte_eth_softnic_internals.h" #include "rte_eth_softnic.h" @@ -1915,6 +1916,53 @@ pmd_flow_destroy(struct rte_eth_dev *dev, return 0; } +static int +pmd_flow_flush(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + struct pmd_internals *softnic = dev->data->dev_private; + struct pipeline *pipeline; + int fail_to_del_rule = 0; + uint32_t i; + + TAILQ_FOREACH(pipeline, &softnic->pipeline_list, node) { + /* Remove all the flows added to the tables. */ + for (i = 0; i < pipeline->n_tables; i++) { + struct softnic_table *table = &pipeline->table[i]; + struct rte_flow *flow; + void *temp; + int status; + + TAILQ_FOREACH_SAFE(flow, &table->flows, node, temp) { + /* Rule delete. */ + status = softnic_pipeline_table_rule_delete + (softnic, + pipeline->name, + i, + &flow->match); + if (status) + fail_to_del_rule = 1; + /* Update dependencies */ + if (is_meter_action_enable(softnic, table)) + flow_meter_owner_reset(softnic, flow); + + /* Flow delete. */ + TAILQ_REMOVE(&table->flows, flow, node); + free(flow); + } + } + } + + if (fail_to_del_rule) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Some of the rules could not be deleted"); + + return 0; +} + static int pmd_flow_query(struct rte_eth_dev *dev __rte_unused, struct rte_flow *flow, @@ -1971,7 +2019,7 @@ const struct rte_flow_ops pmd_flow_ops = { .validate = pmd_flow_validate, .create = pmd_flow_create, .destroy = pmd_flow_destroy, - .flush = NULL, + .flush = pmd_flow_flush, .query = pmd_flow_query, .isolate = NULL, }; -- 2.17.1