DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, nirranjan@chelsio.com
Subject: [dpdk-dev] [PATCH 4/5] net/cxgbe: fix SMT leak in filter error and free path
Date: Sat, 13 Jun 2020 03:37:26 +0530
Message-ID: <fee723ea666a7d525dec05a9bd7ee42d239dd18d.1591998771.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1591998771.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1591998771.git.rahul.lakkireddy@chelsio.com>

Free up Source MAC Table (SMT) entry properly during filter create
failure and filter delete.

Fixes: 993541b2fa4f ("net/cxgbe: support flow API for source MAC rewrite")
Cc: stable@dpdk.org

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/cxgbe_filter.c | 28 ++++++++++++++--------------
 drivers/net/cxgbe/smt.c          |  6 ++++++
 drivers/net/cxgbe/smt.h          |  1 +
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c
index 317830f58..6066da7db 100644
--- a/drivers/net/cxgbe/cxgbe_filter.c
+++ b/drivers/net/cxgbe/cxgbe_filter.c
@@ -302,6 +302,9 @@ static void clear_filter(struct filter_entry *f)
 	if (f->fs.mask.macidx)
 		cxgbe_mpstcam_remove(pi, f->fs.val.macidx);
 
+	if (f->smt)
+		cxgbe_smt_release(f->smt);
+
 	/* The zeroing of the filter rule below clears the filter valid,
 	 * pending, locked flags etc. so it's all we need for
 	 * this operation.
@@ -777,20 +780,6 @@ static int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 	unsigned int port_id = ethdev2pinfo(dev)->port_id;
 	int ret;
 
-	/* If the new filter requires Source MAC rewriting then we need to
-	 * allocate a SMT entry for the filter
-	 */
-	if (f->fs.newsmac) {
-		f->smt = cxgbe_smt_alloc_switching(f->dev, f->fs.smac);
-		if (!f->smt) {
-			if (f->l2t) {
-				cxgbe_l2t_release(f->l2t);
-				f->l2t = NULL;
-			}
-			return -ENOMEM;
-		}
-	}
-
 	ctrlq = &adapter->sge.ctrlq[port_id];
 	mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool);
 	if (!mbuf) {
@@ -1122,6 +1111,17 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id,
 		}
 	}
 
+	/* If the new filter requires Source MAC rewriting then we need to
+	 * allocate a SMT entry for the filter
+	 */
+	if (f->fs.newsmac) {
+		f->smt = cxgbe_smt_alloc_switching(f->dev, f->fs.smac);
+		if (!f->smt) {
+			ret = -ENOMEM;
+			goto free_tid;
+		}
+	}
+
 	iconf = adapter->params.tp.ingress_config;
 
 	/* Either PFVF or OVLAN can be active, but not both
diff --git a/drivers/net/cxgbe/smt.c b/drivers/net/cxgbe/smt.c
index e8f38676e..b7b5a4a02 100644
--- a/drivers/net/cxgbe/smt.c
+++ b/drivers/net/cxgbe/smt.c
@@ -193,6 +193,12 @@ struct smt_entry *cxgbe_smt_alloc_switching(struct rte_eth_dev *dev, u8 *smac)
 	return t4_smt_alloc_switching(dev, 0x0, smac);
 }
 
+void cxgbe_smt_release(struct smt_entry *e)
+{
+	if (rte_atomic32_read(&e->refcnt))
+		rte_atomic32_dec(&e->refcnt);
+}
+
 /**
  * Initialize Source MAC Table
  */
diff --git a/drivers/net/cxgbe/smt.h b/drivers/net/cxgbe/smt.h
index be1fab8ba..92c63c876 100644
--- a/drivers/net/cxgbe/smt.h
+++ b/drivers/net/cxgbe/smt.h
@@ -39,6 +39,7 @@ void t4_cleanup_smt(struct adapter *adap);
 void cxgbe_do_smt_write_rpl(struct adapter *adap,
 			    const struct cpl_smt_write_rpl *rpl);
 struct smt_entry *cxgbe_smt_alloc_switching(struct rte_eth_dev *dev, u8 *smac);
+void cxgbe_smt_release(struct smt_entry *e);
 
 #endif  /* __CXGBE_SMT_H_ */
 
-- 
2.24.0


  parent reply	other threads:[~2020-06-12 22:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12 22:07 [dpdk-dev] [PATCH 0/5] net/cxgbe: fix rte_flow related hardware resource leaks Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 1/5] net/cxgbe: fix CLIP leak in filter error path Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 2/5] net/cxgbe: fix L2T leak in filter error and free path Rahul Lakkireddy
2020-06-12 22:07 ` [dpdk-dev] [PATCH 3/5] net/cxgbe: fix double MPS alloc due to flow validate and create Rahul Lakkireddy
2020-06-12 22:07 ` Rahul Lakkireddy [this message]
2020-06-12 22:07 ` [dpdk-dev] [PATCH 5/5] net/cxgbe: ignore flow default masks for unrequested fields Rahul Lakkireddy
2020-06-17 13:33 ` [dpdk-dev] [dpdk-stable] [PATCH 0/5] net/cxgbe: fix rte_flow related hardware resource leaks 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=fee723ea666a7d525dec05a9bd7ee42d239dd18d.1591998771.git.rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=nirranjan@chelsio.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git