[3/8] net/mlx5/hws: context changes to support unified domain

Message ID 20250216110414.10926-3-hamdani@nvidia.com (mailing list archive)
State Awaiting Upstream
Delegated to: Raslan Darawsheh
Headers
Series [1/8] net/mlx5/hws: introduce capability for unified mode |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hamdan Igbaria Feb. 16, 2025, 11:04 a.m. UTC
From: Erez Shitrit <erezsh@nvidia.com>

Context creates its pools according to the table type.

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_context.c | 21 ++++++++++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_context.h |  3 +++
 2 files changed, 23 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_context.c b/drivers/net/mlx5/hws/mlx5dr_context.c
index 24741afe58..91d05f1f86 100644
--- a/drivers/net/mlx5/hws/mlx5dr_context.c
+++ b/drivers/net/mlx5/hws/mlx5dr_context.c
@@ -19,6 +19,24 @@  uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx)
 	return MLX5_IFC_RTC_REPARSE_ALWAYS;
 }
 
+void mlx5dr_context_set_pool_tbl_attr(struct mlx5dr_pool_attr *attr,
+				      enum mlx5dr_table_type table_type)
+{
+	attr->table_type = table_type;
+
+	switch (table_type) {
+	case MLX5DR_TABLE_TYPE_FDB_TX:
+		attr->opt_type = MLX5DR_POOL_OPTIMIZE_ORIG;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB_RX:
+		attr->opt_type = MLX5DR_POOL_OPTIMIZE_MIRROR;
+		break;
+	default:
+		attr->opt_type = MLX5DR_POOL_OPTIMIZE_NONE;
+		break;
+	}
+}
+
 static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx,
 				     struct mlx5dr_context_attr *attr)
 {
@@ -41,7 +59,8 @@  static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx,
 	pool_attr.alloc_log_sz = RTE_MAX(max_log_sz, ctx->caps->stc_alloc_log_gran);
 
 	for (i = 0; i < MLX5DR_TABLE_TYPE_MAX; i++) {
-		pool_attr.table_type = i;
+		mlx5dr_context_set_pool_tbl_attr(&pool_attr,
+						 (enum mlx5dr_table_type)i);
 		ctx->stc_pool[i] = mlx5dr_pool_create(ctx, &pool_attr);
 		if (!ctx->stc_pool[i]) {
 			DR_LOG(ERR, "Failed to allocate STC pool [%d]", i);
diff --git a/drivers/net/mlx5/hws/mlx5dr_context.h b/drivers/net/mlx5/hws/mlx5dr_context.h
index 7678232ecc..e89a093c77 100644
--- a/drivers/net/mlx5/hws/mlx5dr_context.h
+++ b/drivers/net/mlx5/hws/mlx5dr_context.h
@@ -72,4 +72,7 @@  bool mlx5dr_context_cap_dynamic_reparse(struct mlx5dr_context *ctx);
 
 uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx);
 
+void mlx5dr_context_set_pool_tbl_attr(struct mlx5dr_pool_attr *attr,
+				      enum mlx5dr_table_type table_type);
+
 #endif /* MLX5DR_CONTEXT_H_ */