DPDK patches and discussions
 help / color / mirror / Atom feed
From: Erez Shitrit <erezsh@nvidia.com>
To: <dev@dpdk.org>
Cc: <stable@dpdk.org>, Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH v4] net/mlx5/hws: fix shared context to use local defaults
Date: Wed, 22 Mar 2023 16:42:57 +0200	[thread overview]
Message-ID: <20230322144258.655953-1-erezsh@nvidia.com> (raw)
In-Reply-To: <20230322101621.642765-2-erezsh@nvidia.com>


Every Flow-table has a default miss behavior, meaning what action
to do in case of miss in that Flow-table.
When we are using shared Flow-table we should not use the shared
default instead we should use the default of the local Flow-table
that pointed by the shared Flow-table.

There are two cases that need to be fixed:
When the table created, the default miss should go to the alias ft
that will direct it back to local context.

And also when the rule is without specific hit address and we are
in a shared RTC from here it should be redirected back to the local
context.

Fixes: ce946c7d3999 ("net/mlx5/hws: support ibv context shared with local one")
Cc: stable@dpdk.org

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_action.c |  9 ++++++++-
 drivers/net/mlx5/hws/mlx5dr_table.c  | 29 ++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index 2db62635c1..77cf1f5132 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -1751,8 +1751,15 @@ int mlx5dr_action_get_default_stc(struct mlx5dr_context *ctx,
 		goto free_nop_dw6;
 	}
 
-	stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_ALLOW;
 	stc_attr.action_offset = MLX5DR_ACTION_OFFSET_HIT;
+	if (!mlx5dr_context_shared_gvmi_used(ctx)) {
+		stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_ALLOW;
+	} else {
+		/* On shared gvmi the default hit behavior is jump to alias end ft */
+		stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_FT;
+		stc_attr.dest_table_id = ctx->gvmi_res[tbl_type].aliased_end_ft->id;
+	}
+
 	ret = mlx5dr_action_alloc_single_stc(ctx, &stc_attr, tbl_type,
 					     &default_stc->default_hit);
 	if (ret) {
diff --git a/drivers/net/mlx5/hws/mlx5dr_table.c b/drivers/net/mlx5/hws/mlx5dr_table.c
index 327e2ec710..0e5e9b49ab 100644
--- a/drivers/net/mlx5/hws/mlx5dr_table.c
+++ b/drivers/net/mlx5/hws/mlx5dr_table.c
@@ -272,6 +272,9 @@ static void mlx5dr_table_uninit_shared_ctx_res(struct mlx5dr_table *tbl)
 /* called under spin_lock ctx->ctrl_lock */
 static int mlx5dr_table_init_shared_ctx_res(struct mlx5dr_context *ctx, struct mlx5dr_table *tbl)
 {
+	struct mlx5dr_cmd_ft_modify_attr ft_attr = {0};
+	int ret;
+
 	if (!mlx5dr_context_shared_gvmi_used(ctx))
 		return 0;
 
@@ -288,8 +291,22 @@ static int mlx5dr_table_init_shared_ctx_res(struct mlx5dr_context *ctx, struct m
 		goto clean_local_ft;
 	}
 
+	/* On shared gvmi the default behavior is jump to alias end ft */
+	mlx5dr_cmd_set_attr_connect_miss_tbl(tbl->ctx,
+					     tbl->fw_ft_type,
+					     tbl->type,
+					     &ft_attr);
+
+	ret = mlx5dr_cmd_flow_table_modify(tbl->ft, &ft_attr);
+	if (ret) {
+		DR_LOG(ERR, "Failed to point table to its default miss");
+		goto clean_shared_res;
+	}
+
 	return 0;
 
+clean_shared_res:
+	mlx5dr_table_put_shared_gvmi_res(tbl);
 clean_local_ft:
 	mlx5dr_table_destroy_default_ft(tbl, tbl->local_ft);
 	return rte_errno;
@@ -337,20 +354,20 @@ static int mlx5dr_table_init(struct mlx5dr_table *tbl)
 		return rte_errno;
 	}
 
-	ret = mlx5dr_action_get_default_stc(ctx, tbl->type);
+	ret = mlx5dr_table_init_shared_ctx_res(ctx, tbl);
 	if (ret)
 		goto tbl_destroy;
 
-	ret = mlx5dr_table_init_shared_ctx_res(ctx, tbl);
+	ret = mlx5dr_action_get_default_stc(ctx, tbl->type);
 	if (ret)
-		goto put_stc;
+		goto free_shared_ctx;
 
 	pthread_spin_unlock(&ctx->ctrl_lock);
 
 	return 0;
 
-put_stc:
-	mlx5dr_action_put_default_stc(ctx, tbl->type);
+free_shared_ctx:
+	mlx5dr_table_uninit_shared_ctx_res(tbl);
 tbl_destroy:
 	mlx5dr_table_destroy_default_ft(tbl, tbl->ft);
 	pthread_spin_unlock(&ctx->ctrl_lock);
@@ -363,8 +380,8 @@ static void mlx5dr_table_uninit(struct mlx5dr_table *tbl)
 		return;
 	pthread_spin_lock(&tbl->ctx->ctrl_lock);
 	mlx5dr_action_put_default_stc(tbl->ctx, tbl->type);
-	mlx5dr_table_destroy_default_ft(tbl, tbl->ft);
 	mlx5dr_table_uninit_shared_ctx_res(tbl);
+	mlx5dr_table_destroy_default_ft(tbl, tbl->ft);
 	pthread_spin_unlock(&tbl->ctx->ctrl_lock);
 }
 
-- 
2.18.2


  parent reply	other threads:[~2023-03-22 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 10:16 [PATCH] net/mlx5/hws: fix bug in pattern creation Erez Shitrit
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: fix shared context to use local defaults Erez Shitrit
2023-03-22 12:26   ` Raslan Darawsheh
2023-03-22 14:42   ` Erez Shitrit [this message]
2023-03-23  7:20     ` [PATCH v4] " Raslan Darawsheh
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: fix saving of jumbo tag for deletion Erez Shitrit
2023-03-22 14:44   ` [PATCH v4] " Erez Shitrit
2023-03-23  7:20     ` Raslan Darawsheh
2023-03-22 10:16 ` [PATCH] net/mlx5/hws: add check for modify-header actions Erez Shitrit
2023-03-22 14:45   ` [PATCH v4] " Erez Shitrit
2023-03-23  7:21     ` Raslan Darawsheh
2023-03-22 14:41 ` [PATCH v4] net/mlx5/hws: fix bug in pattern creation Erez Shitrit
2023-03-23  7:19   ` 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=20230322144258.655953-1-erezsh@nvidia.com \
    --to=erezsh@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=stable@dpdk.org \
    --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).