DPDK patches and discussions
 help / color / mirror / Atom feed
From: Erez Shitrit <erezsh@nvidia.com>
To: <dev@dpdk.org>
Cc: <valex@nvidia.com>, <rasland@nvidia.com>,
	Matan Azrad <matan@nvidia.com>,
	 Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH v2 09/10] net/mlx5/hws: support actions while shared resources is used
Date: Thu, 5 Jan 2023 15:03:02 +0200	[thread overview]
Message-ID: <20230105130304.537205-10-erezsh@nvidia.com> (raw)
In-Reply-To: <20230105130304.537205-1-erezsh@nvidia.com>


TIR/FT actions are different in the context of shared ibv resource, it
created on the local ibv_context and aliased to the shared ibv_context.
Other actions should be created on the shared ibv resource, new flag was
added to indicates where this object came from.

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr.h        |  5 ++-
 drivers/net/mlx5/hws/mlx5dr_action.c | 60 ++++++++++++++++++++++++++--
 drivers/net/mlx5/hws/mlx5dr_action.h |  3 ++
 drivers/net/mlx5/mlx5_devx.c         |  2 +-
 4 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index aa36e3111f..c0f9a5e984 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -410,12 +410,15 @@ mlx5dr_action_create_dest_vport(struct mlx5dr_context *ctx,
  *	Direct rule TIR devx object.
  * @param[in] flags
  *	Action creation flags. (enum mlx5dr_action_flags)
+ * @param[in] is_local
+ *	indicates where the tir object was created, local gvmi or other gvmi
  * @return pointer to mlx5dr_action on success NULL otherwise.
  */
 struct mlx5dr_action *
 mlx5dr_action_create_dest_tir(struct mlx5dr_context *ctx,
 			      struct mlx5dr_devx_obj *obj,
-			      uint32_t flags);
+			      uint32_t flags,
+			      bool is_local);
 
 /* Create direct rule TAG action.
  *
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index da19c1ca7d..2db62635c1 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -744,7 +744,10 @@ mlx5dr_action_create_dest_table(struct mlx5dr_context *ctx,
 		return NULL;
 
 	if (mlx5dr_action_is_root_flags(flags)) {
-		action->devx_obj = tbl->ft->obj;
+		if (mlx5dr_context_shared_gvmi_used(ctx))
+			action->devx_obj = tbl->local_ft->obj;
+		else
+			action->devx_obj = tbl->ft->obj;
 	} else {
 		ret = mlx5dr_action_create_stcs(action, tbl->ft);
 		if (ret)
@@ -758,10 +761,38 @@ mlx5dr_action_create_dest_table(struct mlx5dr_context *ctx,
 	return NULL;
 }
 
+static int mlx5dr_action_get_dest_tir_obj(struct mlx5dr_context *ctx,
+					  struct mlx5dr_action *action,
+					  struct mlx5dr_devx_obj *obj,
+					  struct mlx5dr_devx_obj **ret_obj)
+{
+	int ret;
+
+	if (mlx5dr_context_shared_gvmi_used(ctx)) {
+		ret = mlx5dr_matcher_create_aliased_obj(ctx,
+							ctx->local_ibv_ctx,
+							ctx->ibv_ctx,
+							ctx->caps->vhca_id,
+							obj->id,
+							MLX5_GENERAL_OBJ_TYPE_TIR_ALIAS,
+							&action->alias.devx_obj);
+		if (ret) {
+			DR_LOG(ERR, "Failed to create tir alias");
+			return rte_errno;
+		}
+		*ret_obj = action->alias.devx_obj;
+	} else {
+		*ret_obj = obj;
+	}
+
+	return 0;
+}
+
 struct mlx5dr_action *
 mlx5dr_action_create_dest_tir(struct mlx5dr_context *ctx,
 			      struct mlx5dr_devx_obj *obj,
-			      uint32_t flags)
+			      uint32_t flags,
+			      bool is_local)
 {
 	struct mlx5dr_action *action;
 	int ret;
@@ -773,6 +804,13 @@ mlx5dr_action_create_dest_tir(struct mlx5dr_context *ctx,
 		return NULL;
 	}
 
+	if (!is_local) {
+		DR_LOG(ERR, "TIR should be created on local ibv_device, flags: 0x%x",
+		       flags);
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
+
 	action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_TIR);
 	if (!action)
 		return NULL;
@@ -780,13 +818,23 @@ mlx5dr_action_create_dest_tir(struct mlx5dr_context *ctx,
 	if (mlx5dr_action_is_root_flags(flags)) {
 		action->devx_obj = obj->obj;
 	} else {
-		ret = mlx5dr_action_create_stcs(action, obj);
-		if (ret)
+		struct mlx5dr_devx_obj *cur_obj = NULL; /*compilation warn*/
+
+		ret = mlx5dr_action_get_dest_tir_obj(ctx, action, obj, &cur_obj);
+		if (ret) {
+			DR_LOG(ERR, "Failed to create tir alias (flags: %d)", flags);
 			goto free_action;
+		}
+
+		ret = mlx5dr_action_create_stcs(action, cur_obj);
+		if (ret)
+			goto clean_obj;
 	}
 
 	return action;
 
+clean_obj:
+	mlx5dr_cmd_destroy_obj(action->alias.devx_obj);
 free_action:
 	simple_free(action);
 	return NULL;
@@ -1589,6 +1637,10 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
 {
 	switch (action->type) {
 	case MLX5DR_ACTION_TYP_TIR:
+		mlx5dr_action_destroy_stcs(action);
+		if (mlx5dr_context_shared_gvmi_used(action->ctx))
+			mlx5dr_cmd_destroy_obj(action->alias.devx_obj);
+		break;
 	case MLX5DR_ACTION_TYP_MISS:
 	case MLX5DR_ACTION_TYP_TAG:
 	case MLX5DR_ACTION_TYP_DROP:
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h
index 9a4827481a..17619c0057 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.h
+++ b/drivers/net/mlx5/hws/mlx5dr_action.h
@@ -138,6 +138,9 @@ struct mlx5dr_action {
 					uint16_t vport_num;
 					uint16_t esw_owner_vhca_id;
 				} vport;
+				struct {
+					struct mlx5dr_devx_obj *devx_obj;
+				} alias;
 			};
 		};
 
diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c
index 02deaac612..f6e1943fd7 100644
--- a/drivers/net/mlx5/mlx5_devx.c
+++ b/drivers/net/mlx5/mlx5_devx.c
@@ -913,7 +913,7 @@ mlx5_devx_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
 	if (hrxq->hws_flags) {
 		hrxq->action = mlx5dr_action_create_dest_tir
 			(priv->dr_ctx,
-			 (struct mlx5dr_devx_obj *)hrxq->tir, hrxq->hws_flags);
+			 (struct mlx5dr_devx_obj *)hrxq->tir, hrxq->hws_flags, true);
 		if (!hrxq->action)
 			goto error;
 		return 0;
-- 
2.18.2


  parent reply	other threads:[~2023-01-05 13:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19  8:24 [PATCH V1 00/11] Support resource sharing among ibv_devices Erez Shitrit
2022-12-19  8:24 ` [PATCH V1 01/11] mailmap: add new contributors to the list Erez Shitrit
2022-12-19  8:24 ` [PATCH V1 02/11] net/mlx5/hws: add capabilities fields for vhca access Erez Shitrit
2022-12-27 15:47   ` Slava Ovsiienko
2023-01-05 13:02   ` [PATCH v2 00/10] Support resource sharing among ibv_devices Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 01/10] net/mlx5/hws: add capabilities fields for vhca access Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 02/10] net/mlx5/hws: remove wrong PRM capability macros Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 03/10] net/mlx5/hws: add PRM definitions for cross-vhca capabilities Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 04/10] net/mlx5/hws: read " Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 05/10] net/mlx5/hws: added allow-other-vhca-access command Erez Shitrit
2023-01-05 13:02     ` [PATCH v2 06/10] net/mlx5/hws: added command to create alias objects Erez Shitrit
2023-01-05 13:03     ` [PATCH v2 07/10] net/mlx5/hws: add vhca identifier ID to the caps Erez Shitrit
2023-01-05 13:03     ` [PATCH v2 08/10] net/mlx5/hws: support shared ibv-context with local one Erez Shitrit
2023-01-05 13:03     ` Erez Shitrit [this message]
2023-01-05 13:03     ` [PATCH v2 10/10] net/mlx5/hws: add debug details for cross gvmi Erez Shitrit
2023-01-10  9:01     ` [PATCH v2 00/10] Support resource sharing among ibv_devices Raslan Darawsheh
2022-12-19  8:24 ` [PATCH V1 03/11] net/mlx5/hws: remove wrong PRM capability macros Erez Shitrit
2022-12-27 15:47   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 04/11] net/mlx5/hws: add PRM definitions for cross-vhca capabilities Erez Shitrit
2022-12-27 15:47   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 05/11] net/mlx5/hws: read " Erez Shitrit
2022-12-27 15:47   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 06/11] net/mlx5/hws: added allow-other-vhca-access command Erez Shitrit
2022-12-27 15:48   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 07/11] net/mlx5/hws: added command to create alias objects Erez Shitrit
2022-12-27 15:48   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 08/11] net/mlx5/hws: add vhca identifier ID to the caps Erez Shitrit
2022-12-27 15:48   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 09/11] net/mlx5/hws: support shared ibv-context with local one Erez Shitrit
2022-12-27 15:49   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 10/11] net/mlx5/hws: support actions while shared resources is used Erez Shitrit
2022-12-27 15:49   ` Slava Ovsiienko
2022-12-19  8:24 ` [PATCH V1 11/11] net/mlx5/hws: add debug details for cross gvmi Erez Shitrit
2022-12-27 15:48   ` Slava Ovsiienko

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=20230105130304.537205-10-erezsh@nvidia.com \
    --to=erezsh@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=valex@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).