[v1,5/5] net/mlx5/hws: support default miss action on FDB

Message ID 20230704104645.19800-5-igozlan@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [v1,1/5] net/mlx5/hws: remove uneeded new line for DR_LOG |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Itamar Gozlan July 4, 2023, 10:46 a.m. UTC
  From: Alex Vesker <valex@nvidia.com>

Add the support for default miss on HWS FDB, this implementation
was missing until now. Default miss can be used for more efficient
miss flow instead of going to an empty matcher or some defecated
empty table.

Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_action.c | 27 ++++++++++++++++++++-------
 drivers/net/mlx5/hws/mlx5dr_table.c  |  6 +-----
 2 files changed, 21 insertions(+), 12 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index 74f4e60863..920099ba5b 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -322,10 +322,12 @@  int mlx5dr_action_root_build_attr(struct mlx5dr_rule_action rule_actions[],
 	return 0;
 }
 
-static bool mlx5dr_action_fixup_stc_attr(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
-					 struct mlx5dr_cmd_stc_modify_attr *fixup_stc_attr,
-					 enum mlx5dr_table_type table_type,
-					 bool is_mirror)
+static bool
+mlx5dr_action_fixup_stc_attr(struct mlx5dr_context *ctx,
+			     struct mlx5dr_cmd_stc_modify_attr *stc_attr,
+			     struct mlx5dr_cmd_stc_modify_attr *fixup_stc_attr,
+			     enum mlx5dr_table_type table_type,
+			     bool is_mirror)
 {
 	struct mlx5dr_devx_obj *devx_obj;
 	bool use_fixup = false;
@@ -348,6 +350,17 @@  static bool mlx5dr_action_fixup_stc_attr(struct mlx5dr_cmd_stc_modify_attr *stc_
 		use_fixup = true;
 		break;
 
+	case MLX5_IFC_STC_ACTION_TYPE_ALLOW:
+		if (fw_tbl_type == FS_FT_FDB_TX || fw_tbl_type == FS_FT_FDB_RX) {
+			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;
+			fixup_stc_attr->vport.esw_owner_vhca_id = ctx->caps->vhca_id;
+			fixup_stc_attr->vport.vport_num = ctx->caps->eswitch_manager_vport_number;
+			use_fixup = true;
+		}
+		break;
+
 	case MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_VPORT:
 		if (stc_attr->vport.vport_num != WIRE_PORT)
 			break;
@@ -397,7 +410,7 @@  int mlx5dr_action_alloc_single_stc(struct mlx5dr_context *ctx,
 	devx_obj_0 = mlx5dr_pool_chunk_get_base_devx_obj(stc_pool, stc);
 
 	/* According to table/action limitation change the stc_attr */
-	use_fixup = mlx5dr_action_fixup_stc_attr(stc_attr, &fixup_stc_attr, table_type, false);
+	use_fixup = mlx5dr_action_fixup_stc_attr(ctx, stc_attr, &fixup_stc_attr, table_type, false);
 	ret = mlx5dr_cmd_stc_modify(devx_obj_0, use_fixup ? &fixup_stc_attr : stc_attr);
 	if (ret) {
 		DR_LOG(ERR, "Failed to modify STC action_type %d tbl_type %d",
@@ -411,7 +424,8 @@  int mlx5dr_action_alloc_single_stc(struct mlx5dr_context *ctx,
 
 		devx_obj_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(stc_pool, stc);
 
-		use_fixup = mlx5dr_action_fixup_stc_attr(stc_attr, &fixup_stc_attr,
+		use_fixup = mlx5dr_action_fixup_stc_attr(ctx, stc_attr,
+							 &fixup_stc_attr,
 							 table_type, true);
 		ret = mlx5dr_cmd_stc_modify(devx_obj_1, use_fixup ? &fixup_stc_attr : stc_attr);
 		if (ret) {
@@ -491,7 +505,6 @@  static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 	case MLX5DR_ACTION_TYP_MISS:
 		attr->action_type = MLX5_IFC_STC_ACTION_TYPE_ALLOW;
 		attr->action_offset = MLX5DR_ACTION_OFFSET_HIT;
-		/* TODO Need to support default miss for FDB */
 		break;
 	case MLX5DR_ACTION_TYP_CTR:
 		attr->id = obj->id;
diff --git a/drivers/net/mlx5/hws/mlx5dr_table.c b/drivers/net/mlx5/hws/mlx5dr_table.c
index c18ee7c552..f91f04d924 100644
--- a/drivers/net/mlx5/hws/mlx5dr_table.c
+++ b/drivers/net/mlx5/hws/mlx5dr_table.c
@@ -24,7 +24,6 @@  mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl)
 	struct mlx5dr_cmd_forward_tbl *default_miss;
 	struct mlx5dr_context *ctx = tbl->ctx;
 	uint8_t tbl_type = tbl->type;
-	uint32_t vport;
 
 	if (tbl->type != MLX5DR_TABLE_TYPE_FDB)
 		return 0;
@@ -38,12 +37,9 @@  mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl)
 	ft_attr.level = tbl->ctx->caps->fdb_ft.max_level; /* The last level */
 	ft_attr.rtc_valid = false;
 
-	assert(ctx->caps->eswitch_manager);
-	vport = ctx->caps->eswitch_manager_vport_number;
-
 	fte_attr.action_flags = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 	fte_attr.destination_type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
-	fte_attr.destination_id = vport;
+	fte_attr.destination_id = ctx->caps->eswitch_manager_vport_number;
 
 	default_miss = mlx5dr_cmd_forward_tbl_create(mlx5dr_context_get_local_ibv(ctx),
 						     &ft_attr, &fte_attr);