Skip to contentSkip to conversation

net/mlx5/hws: fix allocation of STCs

PATCH In review Itamar Gozlan 2 participants 2 messages Oct 29, 2024 – Nov 13, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5/hws: fix allocation of STCs

From: Erez Shitrit <[email protected]>

STC is a limited resource of the HW, and might get consumed till no more contexts can be opened.
So, let the user to define the size of how many STCs to allocate per context.
In case the user has many representors, no need to allocate per each of them the default value of STCs, otherwise after a certain numbers of representors no more STC's will remain in the system.

Fixes b0290e56dd08 ("net/mlx5/hws: add context object")
---
 drivers/net/mlx5/hws/mlx5dr.h         | 4 +++-
 drivers/net/mlx5/hws/mlx5dr_context.c | 9 ++++++---
 drivers/net/mlx5/mlx5_flow.h          | 3 +++
 drivers/net/mlx5/mlx5_flow_hw.c       | 3 +++
 4 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +3 -1
index 0fe39e9c76..8ea653bede 100644
@@ -102,8 +102,10 @@ struct mlx5dr_context_attr {
 	uint16_t queues;
 	uint16_t queue_size;
 	size_t initial_log_ste_memory; /* Currently not in use */
-	/* Optional PD used for allocating res ources */
+	/* Optional PD used for allocating resources */
 	struct ibv_pd *pd;
+	/* Optional the STC array size for that context */
+	size_t initial_log_stc_memory;
 	/* Optional other ctx for resources allocation, all objects will be created on it */
 	struct ibv_context *shared_ibv_ctx;
 	bool bwc; /* add support for backward compatible API*/
drivers/net/mlx5/hws/mlx5dr_context.c +6 -3
index db5e72927a..24741afe58 100644
@@ -19,7 +19,8 @@ uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx)
 	return MLX5_IFC_RTC_REPARSE_ALWAYS;
 }
 
-static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx)
+static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx,
+				     struct mlx5dr_context_attr *attr)
 {
 	struct mlx5dr_pool_attr pool_attr = {0};
 	uint8_t max_log_sz;
@@ -34,7 +35,9 @@ static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx)
 	/* Create an STC pool per FT type */
 	pool_attr.pool_type = MLX5DR_POOL_TYPE_STC;
 	pool_attr.flags = MLX5DR_POOL_FLAGS_FOR_STC_POOL;
-	max_log_sz = RTE_MIN(MLX5DR_POOL_STC_LOG_SZ, ctx->caps->stc_alloc_log_max);
+	if (!attr->initial_log_stc_memory)
+		attr->initial_log_stc_memory = MLX5DR_POOL_STC_LOG_SZ;
+	max_log_sz = RTE_MIN(attr->initial_log_stc_memory, ctx->caps->stc_alloc_log_max);
 	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++) {
@@ -172,7 +175,7 @@ static int mlx5dr_context_init_hws(struct mlx5dr_context *ctx,
 	if (ret)
 		return ret;
 
-	ret = mlx5dr_context_pools_init(ctx);
+	ret = mlx5dr_context_pools_init(ctx, attr);
 	if (ret)
 		goto uninit_pd;
 
drivers/net/mlx5/mlx5_flow.h +3 -0
index 86a1476879..2055129519 100644
@@ -3609,6 +3609,9 @@ flow_hw_get_ipv6_route_ext_mod_id_from_ctx(void *dr_ctx, uint8_t idx)
 void
 mlx5_indirect_list_handles_release(struct rte_eth_dev *dev);
 #ifdef HAVE_MLX5_HWS_SUPPORT
+
+#define MLX5_REPR_STC_MEMORY_LOG 11
+
 struct mlx5_mirror;
 void
 mlx5_hw_mirror_destroy(struct rte_eth_dev *dev, struct mlx5_mirror *mirror);
drivers/net/mlx5/mlx5_flow_hw.c +3 -0
index 0084f81980..0e01453b50 100644
@@ -11769,6 +11769,9 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 	}
 	dr_ctx_attr.pd = priv->sh->cdev->pd;
 	dr_ctx_attr.queues = nb_q_updated;
+	/* Assign initial value of STC numbers for representors. */
+	if (priv->representor)
+		dr_ctx_attr.initial_log_stc_memory = MLX5_REPR_STC_MEMORY_LOG;
 	/* Queue size should all be the same. Take the first one. */
 	dr_ctx_attr.queue_size = _queue_attr[0]->size;
 	if (port_attr->flags & RTE_FLOW_PORT_FLAG_SHARE_INDIRECT) {
Signature · 1 line
2.39.3
Acked-by Dariusz Sosnowski on v1 1/1
#1 lore raw

Hi,

From: Itamar Gozlan <[email protected]>
Sent: Tuesday, October 29, 2024 3:24 PM
To: Itamar Gozlan; Erez Shitrit; Bing Zhao; NBU-Contact-Thomas Monjalon (EXTERNAL); Suanming Mou; Dariusz Sosnowski; Slava Ovsiienko; Ori Kam; Matan Azrad; Alex Vesker
Cc: [email protected]; [email protected]
Subject: [PATCH] net/mlx5/hws: fix allocation of STCs

From: Erez Shitrit <[email protected]>

STC is a limited resource of the HW, and might get consumed till no more contexts can be opened.
So, let the user to define the size of how many STCs to allocate per context.
In case the user has many representors, no need to allocate per each of them the default value of STCs, otherwise after a certain numbers of representors no more STC's will remain in the system.

Fixes b0290e56dd08 ("net/mlx5/hws: add context object")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh