Skip to content

Commit 37d54bc

Browse files
kliteyngregkh
authored andcommitted
net/mlx5: HWS, fix complex rules rehash error flow
[ Upstream commit 4a842b1 ] Moving rules from matcher to matcher should not fail. However, if it does fail due to various reasons, the error flow should allow the kernel to continue functioning (albeit with broken steering rules) instead of going into series of soft lock-ups or some other problematic behaviour. Similar to the simple rules, complex rules rehash logic suffers from the same problems. This patch fixes the error flow for moving complex rules: - If new rule creation fails before it was even enqeued, do not poll for completion - If TIMEOUT happened while moving the rule, no point trying to poll for completions for other rules. Something is broken, completion won't come, just abort the rehash sequence. - If some other completion with error received, don't give up. Continue handling rest of the rules to minimize the damage. - Make sure that the first error code that was received will be actually returned to the caller instead of replacing it with the generic error code. All the aforementioned issues stem from the same bad error flow, so no point fixing them one by one and leaving partially broken code - fixing them in one patch. Fixes: 17e0acc ("net/mlx5: HWS, support complex matchers") Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Reviewed-by: Vlad Dogaru <vdogaru@nvidia.com> Signed-off-by: Mark Bloch <mbloch@nvidia.com> Link: https://patch.msgid.link/20250817202323.308604-4-mbloch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 748528f commit 37d54bc

File tree

1 file changed

+28
-13
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/steering/hws

1 file changed

+28
-13
lines changed

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,11 +1328,11 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher)
13281328
{
13291329
struct mlx5hws_context *ctx = bwc_matcher->matcher->tbl->ctx;
13301330
struct mlx5hws_matcher *matcher = bwc_matcher->matcher;
1331-
bool move_error = false, poll_error = false;
13321331
u16 bwc_queues = mlx5hws_bwc_queues(ctx);
13331332
struct mlx5hws_bwc_rule *tmp_bwc_rule;
13341333
struct mlx5hws_rule_attr rule_attr;
13351334
struct mlx5hws_table *isolated_tbl;
1335+
int move_error = 0, poll_error = 0;
13361336
struct mlx5hws_rule *tmp_rule;
13371337
struct list_head *rules_list;
13381338
u32 expected_completions = 1;
@@ -1391,23 +1391,35 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher)
13911391
ret = mlx5hws_matcher_resize_rule_move(matcher,
13921392
tmp_rule,
13931393
&rule_attr);
1394-
if (unlikely(ret && !move_error)) {
1395-
mlx5hws_err(ctx,
1396-
"Moving complex BWC rule failed (%d), attempting to move rest of the rules\n",
1397-
ret);
1398-
move_error = true;
1394+
if (unlikely(ret)) {
1395+
if (!move_error) {
1396+
mlx5hws_err(ctx,
1397+
"Moving complex BWC rule: move failed (%d), attempting to move rest of the rules\n",
1398+
ret);
1399+
move_error = ret;
1400+
}
1401+
/* Rule wasn't queued, no need to poll */
1402+
continue;
13991403
}
14001404

14011405
expected_completions = 1;
14021406
ret = mlx5hws_bwc_queue_poll(ctx,
14031407
rule_attr.queue_id,
14041408
&expected_completions,
14051409
true);
1406-
if (unlikely(ret && !poll_error)) {
1407-
mlx5hws_err(ctx,
1408-
"Moving complex BWC rule: poll failed (%d), attempting to move rest of the rules\n",
1409-
ret);
1410-
poll_error = true;
1410+
if (unlikely(ret)) {
1411+
if (ret == -ETIMEDOUT) {
1412+
mlx5hws_err(ctx,
1413+
"Moving complex BWC rule: timeout polling for completions (%d), aborting rehash\n",
1414+
ret);
1415+
return ret;
1416+
}
1417+
if (!poll_error) {
1418+
mlx5hws_err(ctx,
1419+
"Moving complex BWC rule: polling for completions failed (%d), attempting to move rest of the rules\n",
1420+
ret);
1421+
poll_error = ret;
1422+
}
14111423
}
14121424

14131425
/* Done moving the rule to the new matcher,
@@ -1422,8 +1434,11 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher)
14221434
}
14231435
}
14241436

1425-
if (move_error || poll_error)
1426-
ret = -EINVAL;
1437+
/* Return the first error that happened */
1438+
if (unlikely(move_error))
1439+
return move_error;
1440+
if (unlikely(poll_error))
1441+
return poll_error;
14271442

14281443
return ret;
14291444
}

0 commit comments

Comments
 (0)