DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/softnic: add flow flush API
@ 2018-10-01 16:38 Reshma Pattan
  2018-10-02  8:01 ` Singh, Jasvinder
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Reshma Pattan @ 2018-10-01 16:38 UTC (permalink / raw)
  To: dev, cristian.dumitrescu, jasvinder.singh; +Cc: Reshma Pattan

Add rte flow flush api for flushing
all the flows of the port.

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
This patch depends on below patch sets
so must be applied after below patches are applied.
https://mails.dpdk.org/archives/dev/2018-September/111379.html
https://mails.dpdk.org/archives/dev/2018-September/111505.html
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 46 +++++++++++++++++++++-
 1 file changed, 45 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..db0d81dfd 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -1915,6 +1915,50 @@ 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 status;
+	uint32_t i = 0;
+
+	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;
+			struct rte_flow *flow;
+
+			table = &pipeline->table[i];
+			TAILQ_FOREACH(flow, &table->flows, node) {
+				/* Rule delete. */
+				status = softnic_pipeline_table_rule_delete
+						(softnic,
+						flow->pipeline->name,
+						flow->table_id,
+						&flow->match);
+				if (status)
+					return rte_flow_error_set(error,
+						EINVAL,
+						RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+						NULL,
+						"Pipeline table rule delete failed");
+
+			/* 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);
+			}
+		}
+	}
+
+	return 0;
+}
+
 static int
 pmd_flow_query(struct rte_eth_dev *dev __rte_unused,
 	struct rte_flow *flow,
@@ -1971,7 +2015,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] net/softnic: add flow flush API
  2018-10-01 16:38 [dpdk-dev] [PATCH] net/softnic: add flow flush API Reshma Pattan
@ 2018-10-02  8:01 ` Singh, Jasvinder
  2018-10-02 14:27 ` [dpdk-dev] [PATCH v2] " Reshma Pattan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Singh, Jasvinder @ 2018-10-02  8:01 UTC (permalink / raw)
  To: Pattan, Reshma, dev, Dumitrescu, Cristian



<snip>
> --- a/drivers/net/softnic/rte_eth_softnic_flow.c
> +++ b/drivers/net/softnic/rte_eth_softnic_flow.c
> @@ -1915,6 +1915,50 @@ 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 status;
> +	uint32_t i = 0;
> +
> +	TAILQ_FOREACH(pipeline, &softnic->pipeline_list, node) {

Removing elements when iterating tailq lists with TAILQ_FOREACH macro is not safe.
Instead, use TAILQ_FOREACH_SAFE  for safe tailq element removal within the loop.

> +		/* Remove all the flows added to the tables. */
> +		for (i = 0; i < pipeline->n_tables; i++) {
> +			struct softnic_table *table;
> +			struct rte_flow *flow;
> +
> +			table = &pipeline->table[i];
> +			TAILQ_FOREACH(flow, &table->flows, node) {
> +				/* Rule delete. */
> +				status = softnic_pipeline_table_rule_delete
> +						(softnic,
> +						flow->pipeline->name,
> +						flow->table_id,
> +						&flow->match);
> +				if (status)
> +					return rte_flow_error_set(error,
> +						EINVAL,
> +
> 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +						NULL,
> +						"Pipeline table rule delete
> failed");
> +
> +			/* Update dependencies */
> +			if (is_meter_action_enable(softnic, table))
> +				flow_meter_owner_reset(softnic, flow);
Fix Indentation here.
> +				/* Flow delete. */
> +				TAILQ_REMOVE(&table->flows, flow, node);
> +				free(flow);
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static int
>  pmd_flow_query(struct rte_eth_dev *dev __rte_unused,
>  	struct rte_flow *flow,
> @@ -1971,7 +2015,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v2] net/softnic: add flow flush API
  2018-10-01 16:38 [dpdk-dev] [PATCH] net/softnic: add flow flush API Reshma Pattan
  2018-10-02  8:01 ` Singh, Jasvinder
@ 2018-10-02 14:27 ` Reshma Pattan
  2018-10-08  9:10 ` [dpdk-dev] [PATCH v3] " Reshma Pattan
  2018-10-08 11:19 ` [dpdk-dev] [PATCH v4] " Reshma Pattan
  3 siblings, 0 replies; 9+ messages in thread
From: Reshma Pattan @ 2018-10-02 14:27 UTC (permalink / raw)
  To: dev, cristian.dumitrescu, jasvinder.singh; +Cc: Reshma Pattan

Add rte flow flush api for flushing
all the flows of the port.

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
v2: Use TAILQ_FOREACH_SAFE instead of TAILQ_FOREACH
for safe removal using TAILQ_REMOVAL.

Corrected indentation and other style related nits.
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 46 +++++++++++++++++++++-
 1 file changed, 45 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..7931ea13f 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -11,6 +11,7 @@
 #include <rte_string_fns.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
+#include <rte_tailq.h>
 
 #include "rte_eth_softnic_internals.h"
 #include "rte_eth_softnic.h"
@@ -1915,6 +1916,49 @@ 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;
+	uint32_t i;
+	int status;
+
+	TAILQ_FOREACH(pipeline, &softnic->pipeline_list, node) {
+		/* Remove all the flows added to the tables. */
+		for (i = 0; i < pipeline->n_tables; i++) {
+			struct rte_flow *flow;
+			struct softnic_table *table = &pipeline->table[i];
+			void *temp;
+			TAILQ_FOREACH_SAFE(flow, &table->flows, node, temp) {
+				/* Rule delete. */
+				status = softnic_pipeline_table_rule_delete
+						(softnic,
+						pipeline->name,
+						i,
+						&flow->match);
+				if (status)
+					return rte_flow_error_set(error,
+						EINVAL,
+						RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+						NULL,
+						"Pipeline table rule delete failed");
+
+				/* 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);
+			}
+		}
+	}
+
+	return 0;
+}
+
 static int
 pmd_flow_query(struct rte_eth_dev *dev __rte_unused,
 	struct rte_flow *flow,
@@ -1971,7 +2015,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v3] net/softnic: add flow flush API
  2018-10-01 16:38 [dpdk-dev] [PATCH] net/softnic: add flow flush API Reshma Pattan
  2018-10-02  8:01 ` Singh, Jasvinder
  2018-10-02 14:27 ` [dpdk-dev] [PATCH v2] " Reshma Pattan
@ 2018-10-08  9:10 ` Reshma Pattan
  2018-10-08 10:27   ` Singh, Jasvinder
  2018-10-08 10:35   ` Dumitrescu, Cristian
  2018-10-08 11:19 ` [dpdk-dev] [PATCH v4] " Reshma Pattan
  3 siblings, 2 replies; 9+ messages in thread
From: Reshma Pattan @ 2018-10-08  9:10 UTC (permalink / raw)
  To: dev, cristian.dumitrescu, jasvinder.singh; +Cc: Reshma Pattan

Add rte flow flush api for flushing
all the flows of the port.

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
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 | 47 +++++++++++++++++++++-
 1 file changed, 46 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..08ea6e940 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -11,6 +11,7 @@
 #include <rte_string_fns.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
+#include <rte_tailq.h>
 
 #include "rte_eth_softnic_internals.h"
 #include "rte_eth_softnic.h"
@@ -1915,6 +1916,50 @@ 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;
+	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)
+					return rte_flow_error_set(error,
+						EINVAL,
+						RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+						NULL,
+						"Pipeline table rule delete failed");
+
+				/* 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);
+			}
+		}
+	}
+
+	return 0;
+}
+
 static int
 pmd_flow_query(struct rte_eth_dev *dev __rte_unused,
 	struct rte_flow *flow,
@@ -1971,7 +2016,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/softnic: add flow flush API
  2018-10-08  9:10 ` [dpdk-dev] [PATCH v3] " Reshma Pattan
@ 2018-10-08 10:27   ` Singh, Jasvinder
  2018-10-08 10:35   ` Dumitrescu, Cristian
  1 sibling, 0 replies; 9+ messages in thread
From: Singh, Jasvinder @ 2018-10-08 10:27 UTC (permalink / raw)
  To: Pattan, Reshma, dev, Dumitrescu, Cristian



> -----Original Message-----
> From: Pattan, Reshma
> Sent: Monday, October 8, 2018 10:10 AM
> To: dev@dpdk.org; Dumitrescu, Cristian <cristian.dumitrescu@intel.com>;
> Singh, Jasvinder <jasvinder.singh@intel.com>
> Cc: Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH v3] net/softnic: add flow flush API
> 
> Add rte flow flush api for flushing
> all the flows of the port.
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
> 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 | 47 +++++++++++++++++++++-
>  1 file changed, 46 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..08ea6e940 100644
> --- a/drivers/net/softnic/rte_eth_softnic_flow.c
> +++ b/drivers/net/softnic/rte_eth_softnic_flow.c
> @@ -11,6 +11,7 @@
>  #include <rte_string_fns.h>
>  #include <rte_flow.h>
>  #include <rte_flow_driver.h>
> +#include <rte_tailq.h>
> 
>  #include "rte_eth_softnic_internals.h"
>  #include "rte_eth_softnic.h"
> @@ -1915,6 +1916,50 @@ 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;
> +	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)
> +					return rte_flow_error_set(error,
> +						EINVAL,
> +
> 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +						NULL,
> +						"Pipeline table rule delete
> failed");
> +
> +				/* 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);
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static int
>  pmd_flow_query(struct rte_eth_dev *dev __rte_unused,
>  	struct rte_flow *flow,
> @@ -1971,7 +2016,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

Acked-by: Jasvinder Singh <jasvinder.singh@intel.com> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/softnic: add flow flush API
  2018-10-08  9:10 ` [dpdk-dev] [PATCH v3] " Reshma Pattan
  2018-10-08 10:27   ` Singh, Jasvinder
@ 2018-10-08 10:35   ` Dumitrescu, Cristian
  2018-10-08 15:10     ` Pattan, Reshma
  1 sibling, 1 reply; 9+ messages in thread
From: Dumitrescu, Cristian @ 2018-10-08 10:35 UTC (permalink / raw)
  To: Pattan, Reshma, dev, Singh, Jasvinder



> -----Original Message-----
> From: Pattan, Reshma
> Sent: Monday, October 8, 2018 10:10 AM
> To: dev@dpdk.org; Dumitrescu, Cristian <cristian.dumitrescu@intel.com>;
> Singh, Jasvinder <jasvinder.singh@intel.com>
> Cc: Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH v3] net/softnic: add flow flush API
> 
> Add rte flow flush api for flushing
> all the flows of the port.
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
> 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 | 47 +++++++++++++++++++++-
>  1 file changed, 46 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..08ea6e940 100644
> --- a/drivers/net/softnic/rte_eth_softnic_flow.c
> +++ b/drivers/net/softnic/rte_eth_softnic_flow.c
> @@ -11,6 +11,7 @@
>  #include <rte_string_fns.h>
>  #include <rte_flow.h>
>  #include <rte_flow_driver.h>
> +#include <rte_tailq.h>
> 
>  #include "rte_eth_softnic_internals.h"
>  #include "rte_eth_softnic.h"
> @@ -1915,6 +1916,50 @@ 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;
> +	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)
> +					return rte_flow_error_set(error,
> +						EINVAL,
> +
> 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +						NULL,
> +						"Pipeline table rule delete
> failed");

When rule deletion fails, you should not abort, but set up a flag and continue to delete the remaining rules.


> +
> +				/* 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);
> +			}
> +		}
> +	}
> +

This is the place to examine the above mentioned flag and set the error function argument. If error, the error message basically says "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 +2016,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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v4] net/softnic: add flow flush API
  2018-10-01 16:38 [dpdk-dev] [PATCH] net/softnic: add flow flush API Reshma Pattan
                   ` (2 preceding siblings ...)
  2018-10-08  9:10 ` [dpdk-dev] [PATCH v3] " Reshma Pattan
@ 2018-10-08 11:19 ` Reshma Pattan
  2018-10-08 15:33   ` Dumitrescu, Cristian
  3 siblings, 1 reply; 9+ messages in thread
From: Reshma Pattan @ 2018-10-08 11:19 UTC (permalink / raw)
  To: dev, cristian.dumitrescu, jasvinder.singh; +Cc: Reshma Pattan

Add rte flow flush api for flushing
all the flows of the port.

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
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 <rte_string_fns.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
+#include <rte_tailq.h>
 
 #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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/softnic: add flow flush API
  2018-10-08 10:35   ` Dumitrescu, Cristian
@ 2018-10-08 15:10     ` Pattan, Reshma
  0 siblings, 0 replies; 9+ messages in thread
From: Pattan, Reshma @ 2018-10-08 15:10 UTC (permalink / raw)
  To: Dumitrescu, Cristian, dev, Singh, Jasvinder


> -----Original Message-----
> From: Dumitrescu, Cristian
> Sent: Monday, October 8, 2018 11:36 AM
> To: Pattan, Reshma <reshma.pattan@intel.com>; dev@dpdk.org; Singh,
> Jasvinder <jasvinder.singh@intel.com>
> Subject: RE: [PATCH v3] net/softnic: add flow flush API
> 
> 
> 
> > -----Original Message-----
> > From: Pattan, Reshma
> > Sent: Monday, October 8, 2018 10:10 AM
> > To: dev@dpdk.org; Dumitrescu, Cristian
> > <cristian.dumitrescu@intel.com>; Singh, Jasvinder
> > <jasvinder.singh@intel.com>
> > Cc: Pattan, Reshma <reshma.pattan@intel.com>
> > Subject: [PATCH v3] net/softnic: add flow flush API
> >
> > Add rte flow flush api for flushing
> > all the flows of the port.
> >
> > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> > ---
> > 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 | 47
> > +++++++++++++++++++++-
> >  1 file changed, 46 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..08ea6e940 100644
> > --- a/drivers/net/softnic/rte_eth_softnic_flow.c
> > +++ b/drivers/net/softnic/rte_eth_softnic_flow.c
> > @@ -11,6 +11,7 @@
> >  #include <rte_string_fns.h>
> >  #include <rte_flow.h>
> >  #include <rte_flow_driver.h>
> > +#include <rte_tailq.h>
> >
> >  #include "rte_eth_softnic_internals.h"
> >  #include "rte_eth_softnic.h"
> > @@ -1915,6 +1916,50 @@ 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;
> > +	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)
> > +					return rte_flow_error_set(error,
> > +						EINVAL,
> > +
> > 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> > +						NULL,
> > +						"Pipeline table rule delete
> > failed");
> 
> When rule deletion fails, you should not abort, but set up a flag and continue
> to delete the remaining rules.

Done in v4.

> 
> 
> > +
> > +				/* 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);
> > +			}
> > +		}
> > +	}
> > +
> 
> This is the place to examine the above mentioned flag and set the error
> function argument. If error, the error message basically says "some of the
> rules could not be deleted".
> 

Done in v4.

Thanks,
Reshma

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v4] net/softnic: add flow flush API
  2018-10-08 11:19 ` [dpdk-dev] [PATCH v4] " Reshma Pattan
@ 2018-10-08 15:33   ` Dumitrescu, Cristian
  0 siblings, 0 replies; 9+ messages in thread
From: Dumitrescu, Cristian @ 2018-10-08 15:33 UTC (permalink / raw)
  To: Pattan, Reshma, dev, Singh, Jasvinder



> -----Original Message-----
> From: Pattan, Reshma
> Sent: Monday, October 8, 2018 12:19 PM
> To: dev@dpdk.org; Dumitrescu, Cristian <cristian.dumitrescu@intel.com>;
> Singh, Jasvinder <jasvinder.singh@intel.com>
> Cc: Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH v4] net/softnic: add flow flush API
> 
> Add rte flow flush api for flushing
> all the flows of the port.
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
> 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(-)
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied to next-pipeline tree, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-08 15:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 16:38 [dpdk-dev] [PATCH] net/softnic: add flow flush API Reshma Pattan
2018-10-02  8:01 ` Singh, Jasvinder
2018-10-02 14:27 ` [dpdk-dev] [PATCH v2] " Reshma Pattan
2018-10-08  9:10 ` [dpdk-dev] [PATCH v3] " Reshma Pattan
2018-10-08 10:27   ` Singh, Jasvinder
2018-10-08 10:35   ` Dumitrescu, Cristian
2018-10-08 15:10     ` Pattan, Reshma
2018-10-08 11:19 ` [dpdk-dev] [PATCH v4] " Reshma Pattan
2018-10-08 15:33   ` Dumitrescu, Cristian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).