DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: shaguna@chelsio.com, kumaras@chelsio.com, indranil@chelsio.com,
	nirranjan@chelsio.com
Subject: [dpdk-dev] [PATCH 7/7] net/cxgbe: implement flow flush operation
Date: Fri,  8 Jun 2018 23:28:17 +0530	[thread overview]
Message-ID: <93202e988fd013bb7410ea1226c11c73b86a556a.1528469677.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1528469677.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1528469677.git.rahul.lakkireddy@chelsio.com>

From: Shagun Agrawal <shaguna@chelsio.com>

Add API to flush all the filters under specified port.

Signed-off-by: Shagun Agrawal <shaguna@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/cxgbe_filter.h |  1 +
 drivers/net/cxgbe/cxgbe_flow.c   | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cxgbe/cxgbe_filter.h b/drivers/net/cxgbe/cxgbe_filter.h
index 3c81c1a64..70443df4c 100644
--- a/drivers/net/cxgbe/cxgbe_filter.h
+++ b/drivers/net/cxgbe/cxgbe_filter.h
@@ -141,6 +141,7 @@ struct filter_entry {
 	u32 pending:1;              /* filter action is pending FW reply */
 	struct filter_ctx *ctx;     /* caller's completion hook */
 	struct rte_eth_dev *dev;    /* Port's rte eth device */
+	void *private;              /* For use by apps using filter_entry */
 
 	/* This will store the actual tid */
 	u32 tid;
diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c
index 89490ecc2..061947dae 100644
--- a/drivers/net/cxgbe/cxgbe_flow.c
+++ b/drivers/net/cxgbe/cxgbe_flow.c
@@ -468,6 +468,8 @@ cxgbe_flow_create(struct rte_eth_dev *dev,
 		return NULL;
 	}
 
+	flow->f->private = flow; /* Will be used during flush */
+
 	return flow;
 }
 
@@ -632,11 +634,47 @@ cxgbe_flow_validate(struct rte_eth_dev *dev,
 	return 0;
 }
 
+/*
+ * @ret : > 0 filter destroyed succsesfully
+ *        < 0 error destroying filter
+ *        == 1 filter not active / not found
+ */
+static int
+cxgbe_check_n_destroy(struct filter_entry *f, struct rte_eth_dev *dev,
+		      struct rte_flow_error *e)
+{
+	if (f && (f->valid || f->pending) &&
+	    f->dev == dev && /* Only if user has asked for this port */
+	     f->private) /* We (rte_flow) created this filter */
+		return cxgbe_flow_destroy(dev, (struct rte_flow *)f->private,
+					  e);
+	return 1;
+}
+
+static int cxgbe_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *e)
+{
+	struct adapter *adap = ethdev2adap(dev);
+	unsigned int i;
+	int ret = 0;
+
+	if (adap->tids.ftid_tab) {
+		struct filter_entry *f = &adap->tids.ftid_tab[0];
+
+		for (i = 0; i < adap->tids.nftids; i++, f++) {
+			ret = cxgbe_check_n_destroy(f, dev, e);
+			if (ret < 0)
+				goto out;
+		}
+	}
+out:
+	return ret >= 0 ? 0 : ret;
+}
+
 static const struct rte_flow_ops cxgbe_flow_ops = {
 	.validate	= cxgbe_flow_validate,
 	.create		= cxgbe_flow_create,
 	.destroy	= cxgbe_flow_destroy,
-	.flush		= NULL,
+	.flush		= cxgbe_flow_flush,
 	.query		= cxgbe_flow_query,
 	.isolate	= NULL,
 };
-- 
2.14.1

  parent reply	other threads:[~2018-06-08 17:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 17:58 [dpdk-dev] [PATCH 0/7] cxgbe: add support to offload flows via rte_flow Rahul Lakkireddy
2018-06-08 17:58 ` [dpdk-dev] [PATCH 1/7] net/cxgbe: query firmware for filter resources Rahul Lakkireddy
2018-06-13 16:41   ` Ferruh Yigit
2018-06-13 16:59     ` Thomas Monjalon
2018-06-13 17:40       ` Wiles, Keith
2018-06-14  5:44     ` Hemant Agrawal
2018-06-08 17:58 ` [dpdk-dev] [PATCH 2/7] net/cxgbe: parse and validate flows Rahul Lakkireddy
2018-06-08 17:58 ` [dpdk-dev] [PATCH 3/7] net/cxgbe: add control queue to communicate filter requests Rahul Lakkireddy
2018-06-08 17:58 ` [dpdk-dev] [PATCH 4/7] net/cxgbe: implement flow create operation Rahul Lakkireddy
2018-06-08 17:58 ` [dpdk-dev] [PATCH 5/7] net/cxgbe: implement flow destroy operation Rahul Lakkireddy
2018-06-08 17:58 ` [dpdk-dev] [PATCH 6/7] net/cxgbe: implement flow query operation Rahul Lakkireddy
2018-06-08 17:58 ` Rahul Lakkireddy [this message]
2018-06-13 16:42 ` [dpdk-dev] [PATCH 0/7] cxgbe: add support to offload flows via rte_flow Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93202e988fd013bb7410ea1226c11c73b86a556a.1528469677.git.rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=indranil@chelsio.com \
    --cc=kumaras@chelsio.com \
    --cc=nirranjan@chelsio.com \
    --cc=shaguna@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).