[9/9] net/mlx5/hws: support push_esp flag for insert header action

Message ID 20240213095038.451299-9-igozlan@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [1/9] net/mlx5/hws: skip RTE item when inserting rules by index |

Checks

Context Check Description
ci/checkpatch warning coding style issues
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/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Itamar Gozlan Feb. 13, 2024, 9:50 a.m. UTC
  From: Hamdan Igbaria <hamdani@nvidia.com>

support push_esp flag for insert header action, it must be set when
inserting an ESP header, it's also sets the next_protocol field in
the IPsec trailer.

Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/mlx5_prm.h       | 3 ++-
 drivers/net/mlx5/hws/mlx5dr.h        | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.c | 4 ++++
 drivers/net/mlx5/hws/mlx5dr_action.h | 1 +
 drivers/net/mlx5/hws/mlx5dr_cmd.c    | 2 ++
 drivers/net/mlx5/hws/mlx5dr_cmd.h    | 1 +
 6 files changed, 14 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index abff8e4dc3..6fa5553215 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -3608,7 +3608,8 @@  struct mlx5_ifc_stc_ste_param_insert_bits {
 	u8 action_type[0x4];
 	u8 encap[0x1];
 	u8 inline_data[0x1];
-	u8 reserved_at_6[0x4];
+	u8 push_esp[0x1];
+	u8 reserved_at_7[0x3];
 	u8 insert_anchor[0x6];
 	u8 reserved_at_10[0x1];
 	u8 insert_offset[0x7];
diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h
index c11ec08616..78b16f3dc7 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -192,6 +192,10 @@  struct mlx5dr_action_insert_header {
 	 * requiring device to update offloaded fields (for example IPv4 total length).
 	 */
 	bool encap;
+	/* It must be set when adding ESP header.
+	 * It's also sets the next_protocol value in the ipsec trailer.
+	 */
+	bool push_esp;
 };
 
 enum mlx5dr_action_remove_header_type {
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c
index 8589de5557..f55069c675 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.c
+++ b/drivers/net/mlx5/hws/mlx5dr_action.c
@@ -598,6 +598,7 @@  static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT;
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->insert_header.encap = action->reformat.encap;
+		attr->insert_header.push_esp = action->reformat.push_esp;
 		attr->insert_header.insert_anchor = action->reformat.anchor;
 		attr->insert_header.arg_id = action->reformat.arg_obj->id;
 		attr->insert_header.header_size = action->reformat.header_size;
@@ -635,6 +636,7 @@  static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
 		attr->action_offset = MLX5DR_ACTION_OFFSET_DW6;
 		attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS;
 		attr->insert_header.encap = 0;
+		attr->insert_header.push_esp = 0;
 		attr->insert_header.is_inline = 1;
 		attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 		attr->insert_header.insert_offset = MLX5DR_ACTION_HDR_LEN_L2_MACS;
@@ -1340,6 +1342,7 @@  mlx5dr_action_handle_insert_with_ptr(struct mlx5dr_action *action,
 			action[i].reformat.anchor = MLX5_HEADER_ANCHOR_PACKET_START;
 			action[i].reformat.offset = 0;
 			action[i].reformat.encap = 1;
+			action[i].reformat.push_esp = 0;
 		}
 
 		if (likely(reparse == MLX5DR_ACTION_STC_REPARSE_DEFAULT))
@@ -2087,6 +2090,7 @@  mlx5dr_action_create_insert_header_reparse(struct mlx5dr_context *ctx,
 
 		action[i].reformat.anchor = hdrs[i].anchor;
 		action[i].reformat.encap = hdrs[i].encap;
+		action[i].reformat.push_esp = hdrs[i].push_esp;
 		action[i].reformat.offset = hdrs[i].offset;
 		reformat_hdrs[i].sz = hdrs[i].hdr.sz;
 		reformat_hdrs[i].data = hdrs[i].hdr.data;
diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h
index a8d9720c42..0c8e4bbb5a 100644
--- a/drivers/net/mlx5/hws/mlx5dr_action.h
+++ b/drivers/net/mlx5/hws/mlx5dr_action.h
@@ -149,6 +149,7 @@  struct mlx5dr_action {
 					uint8_t offset;
 					bool encap;
 					uint8_t require_reparse;
+					bool push_esp;
 				} reformat;
 				struct {
 					struct mlx5dr_action
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c
index 876a47147d..28d909df80 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.c
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c
@@ -486,6 +486,8 @@  mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr,
 			 MLX5_MODIFICATION_TYPE_INSERT);
 		MLX5_SET(stc_ste_param_insert, stc_parm, encap,
 			 stc_attr->insert_header.encap);
+		MLX5_SET(stc_ste_param_insert, stc_parm, push_esp,
+			 stc_attr->insert_header.push_esp);
 		MLX5_SET(stc_ste_param_insert, stc_parm, inline_data,
 			 stc_attr->insert_header.is_inline);
 		MLX5_SET(stc_ste_param_insert, stc_parm, insert_anchor,
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.h b/drivers/net/mlx5/hws/mlx5dr_cmd.h
index 18c2b07fc8..013a7e99e8 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.h
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.h
@@ -122,6 +122,7 @@  struct mlx5dr_cmd_stc_modify_attr {
 			uint8_t encap;
 			uint16_t insert_anchor;
 			uint16_t insert_offset;
+			uint8_t push_esp;
 		} insert_header;
 		struct {
 			uint8_t aso_type;