Skip to contentSkip to conversation

net/mlx5/hws: introduce capability for unified mode

PATCH In review Hamdan Igbaria 2 participants 9 messages Feb 16, 2025 – Feb 24, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 net/mlx5/hws: introduce capability for unified mode

From: Erez Shitrit <[email protected]>

Till now the FDB processing domain is split into two mutually exclusive sub domains FDB_RX and FDB_TX.
Packets originating from the Uplink(s) are processed in the FDB_RX sub domain, while packets originating from all other Vports are processed in the FDB_TX sub domain.

Now adding new sub domain: FDB_UNIFIED which can process packets originated by any VPORT / WIRE.
This new domain will process actions only that allowed on both RX and TX domains.
That way the user can define specifically the domain he wants the packet to be processed, whenever it is RX/TX only he will use FDB_RX/TX, or whenever it can by FDB_UNIFIED.

---
 drivers/common/mlx5/mlx5_prm.h    | 4 +++-
 drivers/net/mlx5/hws/mlx5dr_cmd.c | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_cmd.h | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_prm.h +3 -1
index d0cb0131f6..6e141b6520 100644
@@ -2478,7 +2478,9 @@ struct mlx5_ifc_wqe_based_flow_table_cap_bits {
 	u8 ste_format_gen_wqe[0x10];
 	u8 linear_match_definer_reg_c3[0x20];
 	u8 fdb_jump_to_tir_stc[0x1];
-	u8 reserved_at_1c1[0x1f];
+	u8 reserved_at_1c1[0x1];
+	u8 fdb_unified_en[0x1];
+	u8 reserved_at_1c3[0x1d];
 };
 
 union mlx5_ifc_hca_cap_union_bits {
drivers/net/mlx5/hws/mlx5dr_cmd.c +4 -0
index a4f778a8a4..8a788709b5 100644
@@ -1276,6 +1276,10 @@ int mlx5dr_cmd_query_caps(struct ibv_context *ctx,
 		caps->fdb_tir_stc = MLX5_GET(query_hca_cap_out, out,
 					     capability.wqe_based_flow_table_cap.
 					     fdb_jump_to_tir_stc);
+
+		caps->fdb_unified_en = MLX5_GET(query_hca_cap_out, out,
+						capability.wqe_based_flow_table_cap.
+						fdb_unified_en);
 	}
 
 	if (caps->eswitch_manager) {
drivers/net/mlx5/hws/mlx5dr_cmd.h +1 -0
index 54840ec445..3c615b8925 100644
@@ -250,6 +250,7 @@ struct mlx5dr_cmd_query_caps {
 	bool roce;
 	uint16_t roce_max_src_udp_port;
 	uint16_t roce_min_src_udp_port;
+	bool fdb_unified_en;
 };
 
 int mlx5dr_cmd_destroy_obj(struct mlx5dr_devx_obj *devx_obj);
Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/8 net/mlx5/hws: add new type to existing table-types

From: Erez Shitrit <[email protected]>

Type MLX5DR_TABLE_TYPE_FDB handles two types of rules and matching one for FDB_RX and one for FDB_TX, now we separate FDB type to 3 sub domains, RX / TX and UNIFIED.
The RX and TX as before, the new one UNIFIED will use for rules / actions that are common to both RX and TX.

---
 drivers/common/mlx5/mlx5_prm.h      |  1 +
 drivers/net/mlx5/hws/mlx5dr.h       |  3 +++
 drivers/net/mlx5/hws/mlx5dr_table.c | 15 +----------
 drivers/net/mlx5/hws/mlx5dr_table.h | 40 ++++++++++++++++++++++++-----
 4 files changed, 39 insertions(+), 20 deletions(-)
drivers/common/mlx5/mlx5_prm.h +1 -0
index 6e141b6520..3fc3b0cd2a 100644
@@ -5122,6 +5122,7 @@ enum {
 	FS_FT_FDB = 0x4,
 	FS_FT_FDB_RX = 0xa,
 	FS_FT_FDB_TX = 0xb,
+	FS_FT_FDB_UNIFIED = 0xc,
 };
 
 struct mlx5_ifc_flow_table_context_bits {
drivers/net/mlx5/hws/mlx5dr.h +3 -0
index 7097d22099..e0e7f5c147 100644
@@ -17,6 +17,9 @@ enum mlx5dr_table_type {
 	MLX5DR_TABLE_TYPE_NIC_RX,
 	MLX5DR_TABLE_TYPE_NIC_TX,
 	MLX5DR_TABLE_TYPE_FDB,
+	MLX5DR_TABLE_TYPE_FDB_RX,
+	MLX5DR_TABLE_TYPE_FDB_TX,
+	MLX5DR_TABLE_TYPE_FDB_UNIFIED,
 	MLX5DR_TABLE_TYPE_MAX,
 };
 
drivers/net/mlx5/hws/mlx5dr_table.c +1 -14
index 634b484a94..d0df40a6c1 100644
@@ -333,20 +333,7 @@ static int mlx5dr_table_init(struct mlx5dr_table *tbl)
 	if (ret)
 		return ret;
 
-	switch (tbl->type) {
-	case MLX5DR_TABLE_TYPE_NIC_RX:
-		tbl->fw_ft_type = FS_FT_NIC_RX;
-		break;
-	case MLX5DR_TABLE_TYPE_NIC_TX:
-		tbl->fw_ft_type = FS_FT_NIC_TX;
-		break;
-	case MLX5DR_TABLE_TYPE_FDB:
-		tbl->fw_ft_type = FS_FT_FDB;
-		break;
-	default:
-		assert(0);
-		break;
-	}
+	mlx5dr_table_get_fw_ft_type(tbl->type, (uint8_t *)&tbl->fw_ft_type);
 
 	pthread_spin_lock(&ctx->ctrl_lock);
 	tbl->ft = mlx5dr_table_create_default_ft(tbl->ctx->ibv_ctx, tbl);
drivers/net/mlx5/hws/mlx5dr_table.h +34 -6
index 32f2574a97..1c0eb6adf8 100644
@@ -32,15 +32,21 @@ static inline
 uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type,
 					 bool is_mirror)
 {
-	if (tbl_type == MLX5DR_TABLE_TYPE_NIC_RX)
+	switch (tbl_type) {
+	case MLX5DR_TABLE_TYPE_NIC_RX:
 		return FS_FT_NIC_RX;
-	else if (tbl_type == MLX5DR_TABLE_TYPE_NIC_TX)
+	case MLX5DR_TABLE_TYPE_NIC_TX:
 		return FS_FT_NIC_TX;
-	else if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
+	case MLX5DR_TABLE_TYPE_FDB:
+	case MLX5DR_TABLE_TYPE_FDB_RX:
+	case MLX5DR_TABLE_TYPE_FDB_TX:
 		return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX;
-
-	assert(0);
-	return 0;
+	case MLX5DR_TABLE_TYPE_FDB_UNIFIED:
+		return FS_FT_FDB_UNIFIED;
+	default:
+		assert(0);
+		return 0;
+	}
 }
 
 static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl)
@@ -48,6 +54,28 @@ static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl)
 	return (tbl->level == MLX5DR_ROOT_LEVEL);
 }
 
+static inline
+void mlx5dr_table_get_fw_ft_type(enum mlx5dr_table_type type,
+				 uint8_t *ret_type)
+{
+	switch (type) {
+	case MLX5DR_TABLE_TYPE_NIC_RX:
+		*ret_type = FS_FT_NIC_RX;
+		break;
+	case MLX5DR_TABLE_TYPE_NIC_TX:
+		*ret_type = FS_FT_NIC_TX;
+		break;
+	case MLX5DR_TABLE_TYPE_FDB:
+	case MLX5DR_TABLE_TYPE_FDB_RX:
+	case MLX5DR_TABLE_TYPE_FDB_TX:
+	case MLX5DR_TABLE_TYPE_FDB_UNIFIED:
+		*ret_type = FS_FT_FDB;
+		break;
+	default:
+		assert(0);
+	}
+}
+
 struct mlx5dr_devx_obj *mlx5dr_table_create_default_ft(struct ibv_context *ibv,
 						       struct mlx5dr_table *tbl);
 
Signature · 1 line
2.21.0
#2 lore raw

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

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

Context creates its pools according to the table type.

---
 drivers/net/mlx5/hws/mlx5dr_context.c | 21 ++++++++++++++++++++-
 drivers/net/mlx5/hws/mlx5dr_context.h |  3 +++
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_context.c +20 -1
index 24741afe58..91d05f1f86 100644
@@ -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);
drivers/net/mlx5/hws/mlx5dr_context.h +3 -0
index 7678232ecc..e89a093c77 100644
@@ -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_ */
Signature · 1 line
2.21.0
#3 lore raw

PATCH 4/8 net/mlx5/hws: allow table creation from the new types

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

Take care of table creation from one of the new types that now exposed to the user (FDB_RX, FDB_TX and FDB_UNIFIED)

---
 drivers/net/mlx5/hws/mlx5dr_action.c |  6 ++---
 drivers/net/mlx5/hws/mlx5dr_cmd.c    |  4 ++--
 drivers/net/mlx5/hws/mlx5dr_table.c  | 35 ++++++++++++++++++++--------
 drivers/net/mlx5/hws/mlx5dr_table.h  | 20 ++++++++++++++++
 4 files changed, 50 insertions(+), 15 deletions(-)
drivers/net/mlx5/hws/mlx5dr_action.c +3 -3
index b038ca6879..8e95abf7da 100644
@@ -801,7 +801,7 @@ mlx5dr_action_fixup_stc_attr(struct mlx5dr_context *ctx,
 		break;
 
 	case MLX5_IFC_STC_ACTION_TYPE_ALLOW:
-		if (fw_tbl_type == FS_FT_FDB_TX || fw_tbl_type == FS_FT_FDB_RX) {
+		if (mlx5dr_table_is_fw_fdb_any(fw_tbl_type)) {
 			fixup_stc_attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_VPORT;
 			fixup_stc_attr->action_offset = stc_attr->action_offset;
 			fixup_stc_attr->stc_offset = stc_attr->stc_offset;
@@ -817,8 +817,8 @@ mlx5dr_action_fixup_stc_attr(struct mlx5dr_context *ctx,
 		if (stc_attr->vport.vport_num != WIRE_PORT)
 			break;
 
-		if (fw_tbl_type == FS_FT_FDB_TX || fw_tbl_type == FS_FT_FDB_RX) {
-			/*The FW doesn't allow to go to wire in the TX/RX by JUMP_TO_VPORT*/
+		if (mlx5dr_table_is_fw_fdb_any(fw_tbl_type)) {
+			/* The FW doesn't allow to go to wire in the TX/RX by JUMP_TO_VPORT */
 			fixup_stc_attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_UPLINK;
 			fixup_stc_attr->action_offset = stc_attr->action_offset;
 			fixup_stc_attr->stc_offset = stc_attr->stc_offset;
drivers/net/mlx5/hws/mlx5dr_cmd.c +2 -2
index 8a788709b5..f609135ccb 100644
@@ -328,14 +328,14 @@ void mlx5dr_cmd_set_attr_connect_miss_tbl(struct mlx5dr_context *ctx,
 {
 	struct mlx5dr_devx_obj *default_miss_tbl;
 
-	if (type != MLX5DR_TABLE_TYPE_FDB && !mlx5dr_context_shared_gvmi_used(ctx))
+	if (!mlx5dr_table_is_fdb_any(type) && !mlx5dr_context_shared_gvmi_used(ctx))
 		return;
 
 	ft_attr->modify_fs = MLX5_IFC_MODIFY_FLOW_TABLE_MISS_ACTION;
 	ft_attr->type = fw_ft_type;
 	ft_attr->table_miss_action = MLX5_IFC_MODIFY_FLOW_TABLE_MISS_ACTION_GOTO_TBL;
 
-	if (type == MLX5DR_TABLE_TYPE_FDB) {
+	if (mlx5dr_table_is_fdb_any(type)) {
 		default_miss_tbl = ctx->common_res[type].default_miss->ft;
 		if (!default_miss_tbl) {
 			assert(false);
drivers/net/mlx5/hws/mlx5dr_table.c +25 -10
index d0df40a6c1..b371f420e6 100644
@@ -8,7 +8,7 @@ static void mlx5dr_table_init_next_ft_attr(struct mlx5dr_table *tbl,
 					   struct mlx5dr_cmd_ft_create_attr *ft_attr)
 {
 	ft_attr->type = tbl->fw_ft_type;
-	if (tbl->type == MLX5DR_TABLE_TYPE_FDB)
+	if (mlx5dr_table_is_fdb_any(tbl->type))
 		ft_attr->level = tbl->ctx->caps->fdb_ft.max_level - 1;
 	else
 		ft_attr->level = tbl->ctx->caps->nic_ft.max_level - 1;
@@ -26,7 +26,7 @@ mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl)
 	struct mlx5dr_context *ctx = tbl->ctx;
 	uint8_t tbl_type = tbl->type;
 
-	if (tbl->type != MLX5DR_TABLE_TYPE_FDB)
+	if (!mlx5dr_table_is_fdb_any(tbl_type))
 		return 0;
 
 	if (ctx->common_res[tbl_type].default_miss) {
@@ -63,7 +63,7 @@ static void mlx5dr_table_down_default_fdb_miss_tbl(struct mlx5dr_table *tbl)
 	struct mlx5dr_context *ctx = tbl->ctx;
 	uint8_t tbl_type = tbl->type;
 
-	if (tbl->type != MLX5DR_TABLE_TYPE_FDB)
+	if (!mlx5dr_table_is_fdb_any(tbl->type))
 		return;
 
 	default_miss = ctx->common_res[tbl_type].default_miss;
@@ -81,7 +81,7 @@ mlx5dr_table_connect_to_default_miss_tbl(struct mlx5dr_table *tbl,
 	struct mlx5dr_cmd_ft_modify_attr ft_attr = {0};
 	int ret;
 
-	assert(tbl->type == MLX5DR_TABLE_TYPE_FDB);
+	assert(mlx5dr_table_is_fdb_any(tbl->type));
 
 	mlx5dr_cmd_set_attr_connect_miss_tbl(tbl->ctx,
 					     tbl->fw_ft_type,
@@ -109,16 +109,18 @@ mlx5dr_table_create_default_ft(struct ibv_context *ibv,
 	mlx5dr_table_init_next_ft_attr(tbl, &ft_attr);
 
 	ft_obj = mlx5dr_cmd_flow_table_create(ibv, &ft_attr);
-	if (ft_obj && tbl->type == MLX5DR_TABLE_TYPE_FDB) {
+	if (ft_obj && mlx5dr_table_is_fdb_any(tbl->type)) {
 		/* Take/create ref over the default miss */
 		ret = mlx5dr_table_up_default_fdb_miss_tbl(tbl);
 		if (ret) {
-			DR_LOG(ERR, "Failed to get default fdb miss");
+			DR_LOG(ERR, "Failed to get default fdb miss for type: %d\n",
+			       tbl->type);
 			goto free_ft_obj;
 		}
 		ret = mlx5dr_table_connect_to_default_miss_tbl(tbl, ft_obj);
 		if (ret) {
-			DR_LOG(ERR, "Failed connecting to default miss tbl");
+			DR_LOG(ERR, "Failed connecting to default miss tbl (type: %d)",
+			       tbl->type);
 			goto down_miss_tbl;
 		}
 	}
@@ -142,7 +144,7 @@ mlx5dr_table_init_check_hws_support(struct mlx5dr_context *ctx,
 		return rte_errno;
 	}
 
-	if (mlx5dr_context_shared_gvmi_used(ctx) && tbl->type == MLX5DR_TABLE_TYPE_FDB) {
+	if (mlx5dr_context_shared_gvmi_used(ctx) && mlx5dr_table_is_fdb_any(tbl->type)) {
 		DR_LOG(ERR, "FDB with shared port resources is not supported");
 		rte_errno = EOPNOTSUPP;
 		return rte_errno;
@@ -380,11 +382,24 @@ struct mlx5dr_table *mlx5dr_table_create(struct mlx5dr_context *ctx,
 	struct mlx5dr_table *tbl;
 	int ret;
 
-	if (attr->type > MLX5DR_TABLE_TYPE_FDB) {
+	if (attr->type >= MLX5DR_TABLE_TYPE_MAX) {
 		DR_LOG(ERR, "Invalid table type %d", attr->type);
 		return NULL;
 	}
 
+	if (attr->type == MLX5DR_TABLE_TYPE_FDB_UNIFIED && !ctx->caps->fdb_unified_en) {
+		DR_LOG(ERR, "Table type %d not supported by current FW", attr->type);
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
+
+	if ((mlx5dr_table_is_fdb_any(attr->type) && attr->type != MLX5DR_TABLE_TYPE_FDB) &&
+	    !attr->level) {
+		DR_LOG(ERR, "Table type %d not supported by root table", attr->type);
+		rte_errno = ENOTSUP;
+		return NULL;
+	}
+
 	tbl = simple_calloc(1, sizeof(*tbl));
 	if (!tbl) {
 		rte_errno = ENOMEM;
@@ -464,7 +479,7 @@ int mlx5dr_table_ft_set_default_next_ft(struct mlx5dr_table *tbl,
 	if (!tbl->ctx->caps->nic_ft.ignore_flow_level_rtc_valid)
 		return 0;
 
-	if (tbl->type == MLX5DR_TABLE_TYPE_FDB)
+	if (mlx5dr_table_is_fdb_any(tbl->type))
 		return mlx5dr_table_connect_to_default_miss_tbl(tbl, ft_obj);
 
 	ft_attr.type = tbl->fw_ft_type;
drivers/net/mlx5/hws/mlx5dr_table.h +20 -0
index 1c0eb6adf8..6996a90d9b 100644
@@ -28,6 +28,26 @@ struct mlx5dr_table {
 	struct mlx5dr_default_miss default_miss;
 };
 
+static inline bool mlx5dr_table_is_fw_fdb_any(uint32_t fw_tbl_type)
+{
+	if (fw_tbl_type == FS_FT_FDB_TX || fw_tbl_type == FS_FT_FDB_RX ||
+	    fw_tbl_type == FS_FT_FDB_UNIFIED)
+		return true;
+
+	return false;
+}
+
+static inline bool mlx5dr_table_is_fdb_any(enum mlx5dr_table_type tbl_type)
+{
+	if (tbl_type == MLX5DR_TABLE_TYPE_FDB ||
+	    tbl_type == MLX5DR_TABLE_TYPE_FDB_TX ||
+	    tbl_type == MLX5DR_TABLE_TYPE_FDB_RX ||
+	    tbl_type == MLX5DR_TABLE_TYPE_FDB_UNIFIED)
+		return true;
+
+	return false;
+}
+
 static inline
 uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type,
 					 bool is_mirror)
Signature · 1 line
2.21.0
#4 lore raw

PATCH 5/8 net/mlx5/hws: matcher changes to support unified domain

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

Matcher for one of the new FDB sub-domains contains specific details according to the type of that sub-domain.

---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 39 ++++++++++++++++++++++++---
 drivers/net/mlx5/hws/mlx5dr_pool.c    |  4 +--
 drivers/net/mlx5/hws/mlx5dr_table.h   |  9 +++++++
 3 files changed, 46 insertions(+), 6 deletions(-)
drivers/net/mlx5/hws/mlx5dr_matcher.c +35 -4
index 54460cc82b..3c84a677d7 100644
@@ -50,7 +50,7 @@ int mlx5dr_matcher_free_rtc_pointing(struct mlx5dr_context *ctx,
 {
 	int ret;
 
-	if (type != MLX5DR_TABLE_TYPE_FDB && !mlx5dr_context_shared_gvmi_used(ctx))
+	if (!mlx5dr_table_is_fdb_any(type) && !mlx5dr_context_shared_gvmi_used(ctx))
 		return 0;
 
 	ret = mlx5dr_table_ft_set_next_rtc(devx_obj, fw_ft_type, NULL, NULL);
@@ -407,6 +407,25 @@ static bool mlx5dr_matcher_supp_fw_wqe(struct mlx5dr_matcher *matcher)
 	return true;
 }
 
+static void mlx5dr_matcher_fixup_rtc_sizes_by_tbl(enum mlx5dr_table_type tbl_type,
+						  bool is_mirror,
+						  struct mlx5dr_cmd_rtc_create_attr *rtc_attr)
+{
+	if (!is_mirror) {
+		if (tbl_type == MLX5DR_TABLE_TYPE_FDB_TX) {
+			/* rtc_0 for TX flow is minimal */
+			rtc_attr->log_size = 0;
+			rtc_attr->log_depth = 0;
+		}
+	} else {
+		if (tbl_type == MLX5DR_TABLE_TYPE_FDB_RX) {
+			/* rtc_1 for RX flow is minimal */
+			rtc_attr->log_size = 0;
+			rtc_attr->log_depth = 0;
+		}
+	}
+}
+
 static void mlx5dr_matcher_set_rtc_attr_sz(struct mlx5dr_matcher *matcher,
 					   struct mlx5dr_cmd_rtc_create_attr *rtc_attr,
 					   enum mlx5dr_matcher_rtc_type rtc_type,
@@ -426,6 +445,11 @@ static void mlx5dr_matcher_set_rtc_attr_sz(struct mlx5dr_matcher *matcher,
 		rtc_attr->log_size = is_match_rtc ? matcher->attr.table.sz_row_log : ste->order;
 		rtc_attr->log_depth = is_match_rtc ? matcher->attr.table.sz_col_log : 0;
 	}
+
+	/* set values according to tbl->type */
+	mlx5dr_matcher_fixup_rtc_sizes_by_tbl(matcher->tbl->type,
+					      is_mirror,
+					      rtc_attr);
 }
 
 int mlx5dr_matcher_create_aliased_obj(struct mlx5dr_context *ctx,
@@ -604,7 +628,7 @@ static int mlx5dr_matcher_create_rtc(struct mlx5dr_matcher *matcher,
 		goto free_ste;
 	}
 
-	if (tbl->type == MLX5DR_TABLE_TYPE_FDB) {
+	if (mlx5dr_table_fdb_no_unified(tbl->type)) {
 		devx_obj = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
 		rtc_attr.ste_base = devx_obj->id;
 		rtc_attr.table_type = mlx5dr_table_get_res_fw_ft_type(tbl->type, true);
@@ -619,6 +643,9 @@ static int mlx5dr_matcher_create_rtc(struct mlx5dr_matcher *matcher,
 			       mlx5dr_matcher_rtc_type_to_str(rtc_type));
 			goto destroy_rtc_0;
 		}
+	} else if (tbl->type == MLX5DR_TABLE_TYPE_FDB_UNIFIED) {
+		/* Unified domain has 2 identical RTC's, allow connecting from other domains */
+		*rtc_1 = *rtc_0;
 	}
 
 	return 0;
@@ -656,7 +683,7 @@ static void mlx5dr_matcher_destroy_rtc(struct mlx5dr_matcher *matcher,
 		return;
 	}
 
-	if (tbl->type == MLX5DR_TABLE_TYPE_FDB)
+	if (mlx5dr_table_fdb_no_unified(tbl->type))
 		mlx5dr_cmd_destroy_obj(rtc_1);
 
 	mlx5dr_cmd_destroy_obj(rtc_0);
@@ -703,6 +730,10 @@ static void mlx5dr_matcher_set_pool_attr(struct mlx5dr_pool_attr *attr,
 	default:
 		break;
 	}
+
+	/* Now set attr according to the table type */
+	if (attr->opt_type == MLX5DR_POOL_OPTIMIZE_NONE)
+		mlx5dr_context_set_pool_tbl_attr(attr, matcher->tbl->type);
 }
 
 static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher,
@@ -1073,7 +1104,7 @@ mlx5dr_matcher_process_attr(struct mlx5dr_cmd_query_caps *caps,
 		return 0;
 	}
 
-	if (matcher->tbl->type != MLX5DR_TABLE_TYPE_FDB  && attr->optimize_flow_src) {
+	if (!mlx5dr_table_is_fdb_any(matcher->tbl->type) && attr->optimize_flow_src) {
 		DR_LOG(ERR, "NIC domain doesn't support flow_src");
 		goto not_supported;
 	}
drivers/net/mlx5/hws/mlx5dr_pool.c +2 -2
index b7b532c7cf..8e3718ac42 100644
@@ -20,7 +20,7 @@ static void mlx5dr_pool_resource_free(struct mlx5dr_pool *pool,
 	mlx5dr_pool_free_one_resource(pool->resource[resource_idx]);
 	pool->resource[resource_idx] = NULL;
 
-	if (pool->tbl_type == MLX5DR_TABLE_TYPE_FDB) {
+	if (mlx5dr_table_fdb_no_unified(pool->tbl_type)) {
 		mlx5dr_pool_free_one_resource(pool->mirror_resource[resource_idx]);
 		pool->mirror_resource[resource_idx] = NULL;
 	}
@@ -89,7 +89,7 @@ mlx5dr_pool_resource_alloc(struct mlx5dr_pool *pool, uint32_t log_range, int idx
 	}
 	pool->resource[idx] = resource;
 
-	if (pool->tbl_type == MLX5DR_TABLE_TYPE_FDB) {
+	if (mlx5dr_table_fdb_no_unified(pool->tbl_type)) {
 		struct mlx5dr_pool_resource *mir_resource;
 
 		fw_ft_type = mlx5dr_table_get_res_fw_ft_type(pool->tbl_type, true);
drivers/net/mlx5/hws/mlx5dr_table.h +9 -0
index 6996a90d9b..a7cdef5d78 100644
@@ -48,6 +48,15 @@ static inline bool mlx5dr_table_is_fdb_any(enum mlx5dr_table_type tbl_type)
 	return false;
 }
 
+static inline bool mlx5dr_table_fdb_no_unified(enum mlx5dr_table_type tbl_type)
+{
+	if (mlx5dr_table_is_fdb_any(tbl_type) &&
+	    tbl_type != MLX5DR_TABLE_TYPE_FDB_UNIFIED)
+		return true;
+
+	return false;
+}
+
 static inline
 uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type,
 					 bool is_mirror)
Signature · 1 line
2.21.0
#5 lore raw

PATCH 6/8 net/mlx5/hws: action changes to support unified domain

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

Actions are depended on the sub-domain that will be used. So handle the actions accordingly.
From now on we don't fix-up for actions that doesn't fit the right domain, we will let it be failed by the FW while creating the STC for it.

---
 drivers/net/mlx5/hws/mlx5dr.h        |   5 +-
 drivers/net/mlx5/hws/mlx5dr_action.c | 222 +++++++++++++++++++++++----
 drivers/net/mlx5/hws/mlx5dr_action.h |   2 +-
 3 files changed, 200 insertions(+), 29 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +4 -1
index e0e7f5c147..58526fc08e 100644
@@ -66,10 +66,13 @@ enum mlx5dr_action_flags {
 	MLX5DR_ACTION_FLAG_HWS_RX = 1 << 3,
 	MLX5DR_ACTION_FLAG_HWS_TX = 1 << 4,
 	MLX5DR_ACTION_FLAG_HWS_FDB = 1 << 5,
+	MLX5DR_ACTION_FLAG_HWS_FDB_RX = 1 << 6,
+	MLX5DR_ACTION_FLAG_HWS_FDB_TX = 1 << 7,
+	MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED = 1 << 8,
 	/* Shared action can be used over a few threads, since data is written
 	 * only once at the creation of the action.
 	 */
-	MLX5DR_ACTION_FLAG_SHARED = 1 << 6,
+	MLX5DR_ACTION_FLAG_SHARED = 1 << 9,
 };
 
 enum mlx5dr_action_aso_meter_color {
drivers/net/mlx5/hws/mlx5dr_action.c +195 -27

358 lines not on this page · raw message

drivers/net/mlx5/hws/mlx5dr_action.h +1 -1
index 8ce4ecd5ba..b779e578fd 100644
@@ -160,7 +160,7 @@ struct mlx5dr_action_template {
 
 struct mlx5dr_action {
 	uint8_t type;
-	uint8_t flags;
+	uint16_t flags;
 	struct mlx5dr_context *ctx;
 	union {
 		struct {
Signature · 1 line
2.21.0
#6 lore raw

PATCH 7/8 net/mlx5/hws: unified rule changes

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

Rule is set according to its specific domain.

---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +18 -5
index 519328ccf3..878224d8b3 100644
@@ -11,18 +11,28 @@ static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher,
 {
 	const struct flow_hw_port_info *vport;
 	const struct rte_flow_item_ethdev *v;
+	enum mlx5dr_table_type type;
 
-	/* Flow_src is the 1st priority */
+	/* By default FDB rules are added to both RX and TX */
+	*skip_rx = false;
+	*skip_tx = false;
+
+	type = matcher->tbl->type;
+	if (type == MLX5DR_TABLE_TYPE_FDB_RX || type == MLX5DR_TABLE_TYPE_FDB_UNIFIED) {
+		*skip_tx = true;
+		return;
+	} else if (type == MLX5DR_TABLE_TYPE_FDB_TX) {
+		*skip_rx = true;
+		return;
+	}
+
+	/* Flow_src is the 1st priority after table type */
 	if (matcher->attr.optimize_flow_src) {
 		*skip_tx = matcher->attr.optimize_flow_src == MLX5DR_MATCHER_FLOW_SRC_WIRE;
 		*skip_rx = matcher->attr.optimize_flow_src == MLX5DR_MATCHER_FLOW_SRC_VPORT;
 		return;
 	}
 
-	/* By default FDB rules are added to both RX and TX */
-	*skip_rx = false;
-	*skip_tx = false;
-
 	if (unlikely(mlx5dr_matcher_is_insert_by_idx(matcher)))
 		return;
 
@@ -88,6 +98,9 @@ static void mlx5dr_rule_init_dep_wqe(struct mlx5dr_send_ring_dep_wqe *dep_wqe,
 		break;
 
 	case MLX5DR_TABLE_TYPE_FDB:
+	case MLX5DR_TABLE_TYPE_FDB_RX:
+	case MLX5DR_TABLE_TYPE_FDB_TX:
+	case MLX5DR_TABLE_TYPE_FDB_UNIFIED:
 		mlx5dr_rule_skip(matcher, mt, items, &skip_rx, &skip_tx);
 
 		if (!skip_rx) {
Signature · 1 line
2.21.0
#7 lore raw

PATCH 8/8 net/mlx5/hws: support debug information for new domains

In reply to Hamdan Igbaria

From: Erez Shitrit <[email protected]>

In order to have the details of the new specific domains.

---
 drivers/net/mlx5/hws/mlx5dr_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_debug.c +2 -2
index 8684a8197a..7480300de8 100644
@@ -232,7 +232,7 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 	ste_pool = matcher->match_ste.pool;
 	if (ste_pool) {
 		ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste);
-		if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
+		if (tbl_type == MLX5DR_TABLE_TYPE_FDB || tbl_type == MLX5DR_TABLE_TYPE_FDB_TX)
 			ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
 	} else {
 		ste_0 = NULL;
@@ -251,7 +251,7 @@ static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
 	ste_pool = matcher->action_ste.pool;
 	if (ste_pool) {
 		ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste);
-		if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
+		if (tbl_type == MLX5DR_TABLE_TYPE_FDB || tbl_type == MLX5DR_TABLE_TYPE_FDB_TX)
 			ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
 	} else {
 		ste_0 = NULL;
Signature · 1 line
2.21.0
Acked-by Matan Azrad on v1 1/8
#8 lore raw
In reply to Hamdan Igbaria

Hi,

From: Hamdan Igbaria <[email protected]>
Sent: Sunday, February 16, 2025 1:04 PM
To: Hamdan Agbariya; Slava Ovsiienko; NBU-Contact-Thomas Monjalon (EXTERNAL); Suanming Mou; Dariusz Sosnowski; Bing Zhao; Ori Kam; Matan Azrad
Cc: [email protected]; Erez Shitrit
Subject: [PATCH 1/8] net/mlx5/hws: introduce capability for unified mode

From: Erez Shitrit <[email protected]>

Till now the FDB processing domain is split into two mutually exclusive sub domains FDB_RX and FDB_TX.
Packets originating from the Uplink(s) are processed in the FDB_RX sub domain, while packets originating from all other Vports are processed in the FDB_TX sub domain.

Now adding new sub domain: FDB_UNIFIED which can process packets originated by any VPORT / WIRE.
This new domain will process actions only that allowed on both RX and TX domains.
That way the user can define specifically the domain he wants the packet to be processed, whenever it is RX/TX only he will use FDB_RX/TX, or whenever it can by FDB_UNIFIED.

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh