From: Hamdan Igbaria <hamd...@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 <hamd...@nvidia.com>
Acked-by: Matan Azrad <ma...@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(-)

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 787211c85c..282e59e52c 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -3616,7 +3616,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 3647e25cf2..d612f300c6 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 f77b194708..4676f65d60 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 694231e08f..ee4a61b7eb 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;
-- 
2.39.3

Reply via email to