DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Itamar Gozlan <igozlan@nvidia.com>
Cc: <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 1/8] net/mlx5/hws: fix leak in FT management
Date: Tue, 31 Oct 2023 16:27:26 +0200	[thread overview]
Message-ID: <20231031142733.2009166-2-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20231031142733.2009166-1-dsosnowski@nvidia.com>

From: Itamar Gozlan <igozlan@nvidia.com>

This commit fixes two leaks in flow table management.
The first leak was when the default miss table of a flow table was not
reset to the default action when setting a new first matcher.
The second leak was caused by a missing free for an RTC in the case of
disconnecting the last matcher in a table's matcher list.

Fixes: b81f95ca770d ("net/mlx5/hws: support default miss table")

Signed-off-by: Itamar Gozlan <igozlan@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 41 +++++++--------------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index a82c182460..ebe42c44c6 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -253,15 +253,15 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher)
 		goto remove_from_list;
 	}
 
-	if (prev) {
-		/* Reset next miss FT to default (drop refcount) */
-		ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev->end_ft);
-		if (ret) {
-			DR_LOG(ERR, "Failed to reset matcher ft default miss");
-			goto remove_from_list;
-		}
-	} else {
-		/* Update tables missing to current table */
+	/* Reset next miss FT to default (drop refcount) */
+	ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev ? prev->end_ft : tbl->ft);
+	if (ret) {
+		DR_LOG(ERR, "Failed to reset matcher ft default miss");
+		goto remove_from_list;
+	}
+
+	if (!prev) {
+		/* Update tables missing to current matcher in the table */
 		ret = mlx5dr_table_update_connected_miss_tables(tbl);
 		if (ret) {
 			DR_LOG(ERR, "Fatal error, failed to update connected miss table");
@@ -276,27 +276,6 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher)
 	return ret;
 }
 
-static int mlx5dr_last_matcher_disconnect(struct mlx5dr_table *tbl,
-					  struct mlx5dr_devx_obj *prev_ft)
-{
-	struct mlx5dr_cmd_ft_modify_attr ft_attr = {0};
-
-	if (tbl->default_miss.miss_tbl) {
-		/* Connect new last matcher to next miss_tbl if exists */
-		return mlx5dr_table_connect_to_miss_table(tbl,
-							  tbl->default_miss.miss_tbl);
-	} else {
-		ft_attr.modify_fs = MLX5_IFC_MODIFY_FLOW_TABLE_RTC_ID;
-		ft_attr.type = tbl->fw_ft_type;
-		/* Matcher is last, point prev end FT to default miss */
-		mlx5dr_cmd_set_attr_connect_miss_tbl(tbl->ctx,
-						     tbl->fw_ft_type,
-						     tbl->type,
-						     &ft_attr);
-		return mlx5dr_cmd_flow_table_modify(prev_ft, &ft_attr);
-	}
-}
-
 static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 {
 	struct mlx5dr_matcher *tmp_matcher, *prev_matcher;
@@ -330,7 +309,7 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 			goto matcher_reconnect;
 		}
 	} else {
-		ret = mlx5dr_last_matcher_disconnect(tbl, prev_ft);
+		ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl);
 		if (ret) {
 			DR_LOG(ERR, "Failed to disconnect last matcher");
 			goto matcher_reconnect;
-- 
2.25.1


  reply	other threads:[~2023-10-31 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 14:27 [PATCH 0/8] net/mlx5: add Multiport E-Switch support Dariusz Sosnowski
2023-10-31 14:27 ` Dariusz Sosnowski [this message]
2023-10-31 14:27 ` [PATCH 2/8] common/mlx5: fix controller index parsing Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 3/8] common/mlx5: add Netlink check for Multiport E-Switch Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 4/8] net/mlx5: add sysfs " Dariusz Sosnowski
2023-10-31 16:09   ` Stephen Hemminger
2023-10-31 17:37     ` Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 5/8] net/mlx5: add checking Multiport E-Switch state Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 6/8] net/mlx5: support port probing of Multiport E-Switch device Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 7/8] net/mlx5: sort port spawn data with uplink ports first Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 8/8] net/mlx5: add support for vport match selection Dariusz Sosnowski
2023-10-31 21:49 ` [PATCH 0/8] net/mlx5: add Multiport E-Switch support Raslan Darawsheh

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=20231031142733.2009166-2-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=igozlan@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.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).