[v2,4/9] net/mlx5/hws: free FT from RTC id before set the new value

Message ID 20230207140206.29139-4-viacheslavo@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [v2,1/9] ethdev: sharing indirect actions between ports |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Slava Ovsiienko Feb. 7, 2023, 2:02 p.m. UTC
  From: Erez Shitrit <erezsh@nvidia.com>

While matcher is being connect/disconnect in shared gvmi flow we set the
first ft in the table to point on the first matcher,
The FW is increasing the refcount on the first matcher RTC because of
that no matcher if it is the same RTC that was set before, and when we
will try to release that RTC we will get the following syndrome:
0xaa0093 -   destroy_rtc_object: rtc in use or doesn't exist.

In order to resolve that we clean the current pointed RTC from that ft
and only after that setting it to the new RTC value.

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index d509a2f0e1..32bf3f5886 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -334,6 +334,24 @@  static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
 		return ret;
 	}
 
+	if (!next) {
+		/* ft no longer points to any RTC, drop refcount */
+		ret = mlx5dr_matcher_free_rtc_pointing(tbl->ctx,
+						       tbl->fw_ft_type,
+						       tbl->type,
+						       prev_ft);
+		if (ret) {
+			DR_LOG(ERR, "Failed to reset last RTC refcount");
+			return ret;
+		}
+	}
+
+	ret = mlx5dr_matcher_shared_update_local_ft(tbl);
+	if (ret) {
+		DR_LOG(ERR, "Failed to update local_ft in shared table");
+		return ret;
+	}
+
 	return 0;
 }