From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: getelson@nvidia.com, <mkashani@nvidia.com>,
rasland@nvidia.com, "Itamar Gozlan" <igozlan@nvidia.com>
Subject: [PATCH] net/mlx5/hws: change error flow on matcher disconnect
Date: Sun, 9 Feb 2025 15:48:06 +0200 [thread overview]
Message-ID: <20250209134806.263338-1-getelson@nvidia.com> (raw)
From: Itamar Gozlan <igozlan@nvidia.com>
Currently, when a firmware (FW) failure occurs during matcher error flow,
the system attempts to reconnect the matcher, leading to a segmentation
fault. This happens because the matcher is freed but remains in the list.
Example scenario:
Given matchers M1->M2->M3, if a FW failure occurs:
1. System tries to destroy M1 and fails
2. M1 remains in the list but is freed
3. When destroying M2, it attempts to remove itself and create M1->M3
4. This results in a segmentation fault as M1 is already freed
Signed-off-by: Itamar Gozlan <igozlan@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr_matcher.c | 31 +++++++++++----------------
1 file changed, 12 insertions(+), 19 deletions(-)
diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index 54460cc82b..c9922546fe 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -290,8 +290,8 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher)
static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
{
- struct mlx5dr_matcher *tmp_matcher, *prev_matcher;
struct mlx5dr_table *tbl = matcher->tbl;
+ struct mlx5dr_matcher *tmp_matcher;
struct mlx5dr_devx_obj *prev_ft;
struct mlx5dr_matcher *next;
int ret;
@@ -302,13 +302,11 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
}
prev_ft = tbl->ft;
- prev_matcher = LIST_FIRST(&tbl->head);
LIST_FOREACH(tmp_matcher, &tbl->head, next) {
if (tmp_matcher == matcher)
break;
prev_ft = tmp_matcher->end_ft;
- prev_matcher = tmp_matcher;
}
next = matcher->next.le_next;
@@ -322,21 +320,21 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
next->match_ste.rtc_0,
next->match_ste.rtc_1);
if (ret) {
- DR_LOG(ERR, "Failed to disconnect matcher");
- goto matcher_reconnect;
+ DR_LOG(ERR, "Fatal: failed to disconnect matcher");
+ return ret;
}
} else {
ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl, true);
if (ret) {
- DR_LOG(ERR, "Failed to disconnect last matcher");
- goto matcher_reconnect;
+ DR_LOG(ERR, "Fatal: failed to disconnect last matcher");
+ return ret;
}
}
ret = mlx5dr_matcher_shared_update_local_ft(tbl);
if (ret) {
- DR_LOG(ERR, "Failed to update local_ft in shared table");
- goto matcher_reconnect;
+ DR_LOG(ERR, "Fatal: failed to update local_ft in shared table");
+ return ret;
}
/* Removing first matcher, update connected miss tables if exists */
@@ -344,25 +342,20 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher)
ret = mlx5dr_table_update_connected_miss_tables(tbl);
if (ret) {
DR_LOG(ERR, "Fatal error, failed to update connected miss table");
- goto matcher_reconnect;
+ return ret;
}
}
ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev_ft);
if (ret) {
DR_LOG(ERR, "Fatal error, failed to restore matcher ft default miss");
- goto matcher_reconnect;
+ return ret;
}
+ /* Failure to restore/modify FW results in a critical, unrecoverable error.
+ * Error handling is not applicable in this fatal scenario.
+ */
return 0;
-
-matcher_reconnect:
- if (LIST_EMPTY(&tbl->head) || prev_matcher == matcher)
- LIST_INSERT_HEAD(&matcher->tbl->head, matcher, next);
- else
- LIST_INSERT_AFTER(prev_matcher, matcher, next);
-
- return ret;
}
static bool mlx5dr_matcher_supp_fw_wqe(struct mlx5dr_matcher *matcher)
--
2.45.2
reply other threads:[~2025-02-09 13:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250209134806.263338-1-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=dev@dpdk.org \
--cc=igozlan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=rasland@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).