DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hamdan Igbaria <hamdani@nvidia.com>
To: <hamdani@nvidia.com>, <viacheslavo@nvidia.com>,
	<thomas@monjalon.net>, <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <orika@nvidia.com>, <valex@nvidia.com>
Subject: [v1 2/3] net/mlx5/hws: dump FT icm addresses
Date: Mon, 20 Mar 2023 16:12:27 +0200	[thread overview]
Message-ID: <20230320141229.104748-2-hamdani@nvidia.com> (raw)
In-Reply-To: <20230320141229.104748-1-hamdani@nvidia.com>

Add the support for query FT command.
Use the query FT command to dump the ICM
addresses of table start anchor and matcher
end anchor.

Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
---
 drivers/common/mlx5/mlx5_prm.h      | 50 ++++++++++++++++++++---
 drivers/net/mlx5/hws/mlx5dr_cmd.c   | 28 +++++++++++++
 drivers/net/mlx5/hws/mlx5dr_cmd.h   |  9 +++++
 drivers/net/mlx5/hws/mlx5dr_debug.c | 62 ++++++++++++++++++++++++++---
 drivers/net/mlx5/hws/mlx5dr_debug.h |  6 +++
 5 files changed, 144 insertions(+), 11 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4b0a56f4e5..6b72039bdd 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -1156,6 +1156,7 @@ enum {
 	MLX5_CMD_OP_CREATE_RQT = 0x916,
 	MLX5_CMD_OP_MODIFY_RQT = 0x917,
 	MLX5_CMD_OP_CREATE_FLOW_TABLE = 0x930,
+	MLX5_CMD_OP_QUERY_FLOW_TABLE = 0x932,
 	MLX5_CMD_OP_CREATE_FLOW_GROUP = 0x933,
 	MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY = 0x936,
 	MLX5_CMD_OP_MODIFY_FLOW_TABLE = 0x93c,
@@ -4872,11 +4873,17 @@ struct mlx5_ifc_flow_table_context_bits {
 
 	u8 reserved_at_60[0x60];
 
-	u8 rtc_id_0[0x20];
-
-	u8 rtc_id_1[0x20];
-
-	u8 reserved_at_100[0x40];
+	union {
+		struct {
+			u8 rtc_id_0[0x20];
+			u8 rtc_id_1[0x20];
+			u8 reserved_at_100[0x40];
+		};
+		struct {
+			u8 sw_owner_icm_root_1[0x40];
+			u8 sw_owner_icm_root_0[0x40];
+		};
+	};
 };
 
 struct mlx5_ifc_create_flow_table_in_bits {
@@ -4909,6 +4916,39 @@ struct mlx5_ifc_create_flow_table_out_bits {
 	u8 icm_address_31_0[0x20];
 };
 
+struct mlx5_ifc_query_flow_table_in_bits {
+	u8 opcode[0x10];
+	u8 uid[0x10];
+
+	u8 vhca_tunnel_id[0x10];
+	u8 op_mod[0x10];
+
+	u8 other_vport[0x1];
+	u8 reserved_at_41[0xf];
+	u8 vport_number[0x10];
+
+	u8 reserved_at_60[0x20];
+
+	u8 table_type[0x8];
+	u8 reserved_at_88[0x18];
+
+	u8 reserved_at_a0[0x8];
+	u8 table_id[0x18];
+
+	u8 reserved_at_c0[0x140];
+};
+
+struct mlx5_ifc_query_flow_table_out_bits {
+	u8 status[0x8];
+	u8 reserved_at_8[0x18];
+
+	u8 syndrome[0x20];
+
+	u8 reserved_at_40[0x80];
+
+	struct mlx5_ifc_flow_table_context_bits flow_table_context;
+};
+
 enum mlx5_flow_destination_type {
 	MLX5_FLOW_DESTINATION_TYPE_VPORT = 0x0,
 };
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c
index a444fb4438..6e7d6eb1ac 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.c
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c
@@ -80,6 +80,34 @@ mlx5dr_cmd_flow_table_modify(struct mlx5dr_devx_obj *devx_obj,
 	return ret;
 }
 
+int
+mlx5dr_cmd_flow_table_query(struct mlx5dr_devx_obj *devx_obj,
+			    struct mlx5dr_cmd_ft_query_attr *ft_attr,
+			    uint64_t *icm_addr_0, uint64_t *icm_addr_1)
+{
+	uint32_t out[MLX5_ST_SZ_DW(query_flow_table_out)] = {0};
+	uint32_t in[MLX5_ST_SZ_DW(query_flow_table_in)] = {0};
+	void *ft_ctx;
+	int ret;
+
+	MLX5_SET(query_flow_table_in, in, opcode, MLX5_CMD_OP_QUERY_FLOW_TABLE);
+	MLX5_SET(query_flow_table_in, in, table_type, ft_attr->type);
+	MLX5_SET(query_flow_table_in, in, table_id, devx_obj->id);
+
+	ret = mlx5_glue->devx_obj_query(devx_obj->obj, in, sizeof(in), out, sizeof(out));
+	if (ret) {
+		DR_LOG(ERR, "Failed to query FT");
+		rte_errno = errno;
+		return ret;
+	}
+
+	ft_ctx = MLX5_ADDR_OF(query_flow_table_out, out, flow_table_context);
+	*icm_addr_0 = MLX5_GET64(flow_table_context, ft_ctx, sw_owner_icm_root_0);
+	*icm_addr_1 = MLX5_GET64(flow_table_context, ft_ctx, sw_owner_icm_root_1);
+
+	return ret;
+}
+
 static struct mlx5dr_devx_obj *
 mlx5dr_cmd_flow_group_create(struct ibv_context *ctx,
 			     struct mlx5dr_cmd_fg_attr *fg_attr)
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.h b/drivers/net/mlx5/hws/mlx5dr_cmd.h
index 3f40c085be..7d03f3d169 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.h
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.h
@@ -22,6 +22,10 @@ struct mlx5dr_cmd_ft_modify_attr {
 	uint64_t modify_fs;
 };
 
+struct mlx5dr_cmd_ft_query_attr {
+	uint8_t type;
+};
+
 struct mlx5dr_cmd_fg_attr {
 	uint32_t table_id;
 	uint32_t table_type;
@@ -215,6 +219,11 @@ int
 mlx5dr_cmd_flow_table_modify(struct mlx5dr_devx_obj *devx_obj,
 			     struct mlx5dr_cmd_ft_modify_attr *ft_attr);
 
+int
+mlx5dr_cmd_flow_table_query(struct mlx5dr_devx_obj *devx_obj,
+			    struct mlx5dr_cmd_ft_query_attr *ft_attr,
+			    uint64_t *icm_addr_0, uint64_t *icm_addr_1);
+
 struct mlx5dr_devx_obj *
 mlx5dr_cmd_rtc_create(struct ibv_context *ctx,
 		      struct mlx5dr_cmd_rtc_create_attr *rtc_attr);
diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c
index e29122aa98..c49b504317 100644
--- a/drivers/net/mlx5/hws/mlx5dr_debug.c
+++ b/drivers/net/mlx5/hws/mlx5dr_debug.c
@@ -198,9 +198,12 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 	bool is_shared = mlx5dr_context_shared_gvmi_used(matcher->tbl->ctx);
 	bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL;
 	enum mlx5dr_table_type tbl_type = matcher->tbl->type;
+	struct mlx5dr_cmd_ft_query_attr ft_attr = {0};
 	struct mlx5dr_devx_obj *ste_0, *ste_1 = NULL;
 	struct mlx5dr_pool_chunk *ste;
 	struct mlx5dr_pool *ste_pool;
+	uint64_t icm_addr_0 = 0;
+	uint64_t icm_addr_1 = 0;
 	int ret;
 
 	ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,0x%" PRIx64,
@@ -243,13 +246,25 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 		ste_1 = NULL;
 	}
 
-	ret = fprintf(f, ",%d,%d,%d,%d,%d\n",
+	if (!is_root) {
+		ft_attr.type = matcher->tbl->fw_ft_type;
+		ret = mlx5dr_cmd_flow_table_query(matcher->end_ft,
+						  &ft_attr,
+						  &icm_addr_0,
+						  &icm_addr_1);
+		if (ret)
+			return ret;
+	}
+
+	ret = fprintf(f, ",%d,%d,%d,%d,%d,0x%" PRIx64 ",0x%" PRIx64 "\n",
 		      matcher->action_ste.rtc_0 ? matcher->action_ste.rtc_0->id : 0,
 		      ste_0 ? (int)ste_0->id : -1,
 		      matcher->action_ste.rtc_1 ? matcher->action_ste.rtc_1->id : 0,
 		      ste_1 ? (int)ste_1->id : -1,
 		      is_shared && !is_root ?
-		      matcher->match_ste.aliased_rtc_0->id : 0);
+		      matcher->match_ste.aliased_rtc_0->id : 0,
+		      mlx5dr_debug_icm_to_idx(icm_addr_0),
+		      mlx5dr_debug_icm_to_idx(icm_addr_1));
 	if (ret < 0)
 		goto out_err;
 
@@ -276,10 +291,15 @@ static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl)
 {
 	bool is_shared = mlx5dr_context_shared_gvmi_used(tbl->ctx);
 	bool is_root = tbl->level == MLX5DR_ROOT_LEVEL;
+	struct mlx5dr_cmd_ft_query_attr ft_attr = {0};
 	struct mlx5dr_matcher *matcher;
+	uint64_t local_icm_addr_0 = 0;
+	uint64_t local_icm_addr_1 = 0;
+	uint64_t icm_addr_0 = 0;
+	uint64_t icm_addr_1 = 0;
 	int ret;
 
-	ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d,%d,%d\n",
+	ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d,%d,%d",
 		      MLX5DR_DEBUG_RES_TYPE_TABLE,
 		      (uint64_t)(uintptr_t)tbl,
 		      (uint64_t)(uintptr_t)tbl->ctx,
@@ -288,11 +308,37 @@ static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl)
 		      is_root ? 0 : tbl->fw_ft_type,
 		      tbl->level,
 		      is_shared && !is_root ? tbl->local_ft->id : 0);
-	if (ret < 0) {
-		rte_errno = EINVAL;
-		return rte_errno;
+	if (ret < 0)
+		goto out_err;
+
+	if (!is_root) {
+		ft_attr.type = tbl->fw_ft_type;
+		ret = mlx5dr_cmd_flow_table_query(tbl->ft,
+						  &ft_attr,
+						  &icm_addr_0,
+						  &icm_addr_1);
+		if (ret)
+			return ret;
+
+		if (is_shared) {
+			ft_attr.type = tbl->fw_ft_type;
+			ret = mlx5dr_cmd_flow_table_query(tbl->local_ft,
+							  &ft_attr,
+							  &local_icm_addr_0,
+							  &local_icm_addr_1);
+			if (ret)
+				return ret;
+		}
 	}
 
+	ret = fprintf(f, ",0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 "\n",
+		      mlx5dr_debug_icm_to_idx(icm_addr_0),
+		      mlx5dr_debug_icm_to_idx(icm_addr_1),
+		      mlx5dr_debug_icm_to_idx(local_icm_addr_0),
+		      mlx5dr_debug_icm_to_idx(local_icm_addr_1));
+	if (ret < 0)
+		goto out_err;
+
 	LIST_FOREACH(matcher, &tbl->head, next) {
 		ret = mlx5dr_debug_dump_matcher(f, matcher);
 		if (ret)
@@ -300,6 +346,10 @@ static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl)
 	}
 
 	return 0;
+
+out_err:
+	rte_errno = EINVAL;
+	return rte_errno;
 }
 
 static int
diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.h b/drivers/net/mlx5/hws/mlx5dr_debug.h
index 0f88e73186..5cffdb10b5 100644
--- a/drivers/net/mlx5/hws/mlx5dr_debug.h
+++ b/drivers/net/mlx5/hws/mlx5dr_debug.h
@@ -26,6 +26,12 @@ enum mlx5dr_debug_res_type {
 	MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_RANGE_DEFINER = 4206,
 };
 
+static inline uint64_t
+mlx5dr_debug_icm_to_idx(uint64_t icm_addr)
+{
+	return (icm_addr >> 6) & 0xffffffff;
+}
+
 const char *mlx5dr_debug_action_type_to_str(enum mlx5dr_action_type action_type);
 
 #endif /* MLX5DR_DEBUG_H_ */
-- 
2.26.3


  reply	other threads:[~2023-03-20 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 14:12 [v1 1/3] net/mlx5/hws: support dest root table action Hamdan Igbaria
2023-03-20 14:12 ` Hamdan Igbaria [this message]
2023-03-20 14:12 ` [v1 3/3] net/mlx5/hws: Enhance forward table and FTE creation Hamdan Igbaria
2023-05-15  8:24 ` [v1 1/3] net/mlx5/hws: support dest root table action Matan Azrad
2023-05-24  9:01 ` 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=20230320141229.104748-2-hamdani@nvidia.com \
    --to=hamdani@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --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).