patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Jin Liu <jin.liu@corigine.com>,
	stable@dpdk.org, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH] net/nfp: only flush specified port flow table
Date: Thu, 16 Feb 2023 14:36:44 +0800	[thread overview]
Message-ID: <20230216063644.13109-1-chaoyong.he@corigine.com> (raw)

From: Jin Liu <jin.liu@corigine.com>

The flow flush function will destroy all the flow table on all the
port of NFP nic rather than the provide port. Modify logic, only
destroy the flow table on the corresponding port.

Fixes: 30ecce522732 ("net/nfp: support flow API")
Cc: stable@dpdk.org

Signed-off-by: Jin Liu <jin.liu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_flow.c | 18 +++++++++++++-----
 drivers/net/nfp/nfp_flow.h |  1 +
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 4d4d21d997..bc28edee4c 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -339,7 +339,7 @@ nfp_flow_table_search(struct nfp_flow_priv *priv,
 }
 
 static struct rte_flow *
-nfp_flow_alloc(struct nfp_fl_key_ls *key_layer)
+nfp_flow_alloc(struct nfp_fl_key_ls *key_layer, uint32_t port_id)
 {
 	char *tmp;
 	size_t len;
@@ -357,6 +357,7 @@ nfp_flow_alloc(struct nfp_fl_key_ls *key_layer)
 
 	nfp_flow->length = len;
 	nfp_flow->mtr_id       = NFP_MAX_MTR_CNT;
+	nfp_flow->port_id      = port_id;
 	payload                = &nfp_flow->payload;
 	payload->meta          = (struct nfp_fl_rule_metadata *)tmp;
 	payload->unmasked_data = tmp + sizeof(struct nfp_fl_rule_metadata);
@@ -3549,7 +3550,7 @@ nfp_flow_process(struct nfp_flower_representor *representor,
 		return NULL;
 	}
 
-	nfp_flow = nfp_flow_alloc(&key_layer);
+	nfp_flow = nfp_flow_alloc(&key_layer, representor->port_id);
 	if (nfp_flow == NULL) {
 		PMD_DRV_LOG(ERR, "Alloc nfp flow failed.");
 		goto free_stats;
@@ -3880,14 +3881,21 @@ nfp_flow_flush(struct rte_eth_dev *dev,
 	void *next_data;
 	uint32_t iter = 0;
 	const void *next_key;
+	struct rte_flow *nfp_flow;
 	struct nfp_flow_priv *priv;
+	struct nfp_flower_representor *representor;
+
+	representor = dev->data->dev_private;
 
 	priv = nfp_flow_dev_to_priv(dev);
 
 	while (rte_hash_iterate(priv->flow_table, &next_key, &next_data, &iter) >= 0) {
-		ret = nfp_flow_destroy(dev, (struct rte_flow *)next_data, error);
-		if (ret != 0)
-			break;
+		nfp_flow = next_data;
+		if (nfp_flow->port_id == representor->port_id) {
+			ret = nfp_flow_destroy(dev, nfp_flow, error);
+			if (ret != 0)
+				break;
+		}
 	}
 
 	return ret;
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index b8da752a9d..d352671c2c 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -223,6 +223,7 @@ struct rte_flow {
 	size_t length;
 	uint32_t hash_key;
 	uint32_t mtr_id;
+	uint32_t port_id;
 	bool install_flag;
 	enum nfp_flow_type type;
 };
-- 
2.29.3


             reply	other threads:[~2023-02-16  6:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16  6:36 Chaoyong He [this message]
2023-02-16 17:08 ` 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=20230216063644.13109-1-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=jin.liu@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=stable@dpdk.org \
    /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).