From: Hamdan Igbaria <hamd...@nvidia.com>

Add the ability to create forward table and FTE.

Signed-off-by: Hamdan Igbaria <hamd...@nvidia.com>
Acked-by: Suanming Mou <suanmi...@nvidia.com>
---
 drivers/common/mlx5/mlx5_prm.h    |  4 ++++
 drivers/net/mlx5/hws/mlx5dr_cmd.c | 13 +++++++++++++
 drivers/net/mlx5/hws/mlx5dr_cmd.h | 19 +++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 4192fff55b..df621b19af 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -5048,7 +5048,11 @@ enum mlx5_flow_destination_type {
 };
 
 enum mlx5_flow_context_action {
+       MLX5_FLOW_CONTEXT_ACTION_DROP = 1 << 1,
        MLX5_FLOW_CONTEXT_ACTION_FWD_DEST = 1 << 2,
+       MLX5_FLOW_CONTEXT_ACTION_REFORMAT = 1 << 4,
+       MLX5_FLOW_CONTEXT_ACTION_DECRYPT = 1 << 12,
+       MLX5_FLOW_CONTEXT_ACTION_ENCRYPT = 1 << 13,
 };
 
 enum mlx5_flow_context_flow_source {
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c 
b/drivers/net/mlx5/hws/mlx5dr_cmd.c
index 0ccbaee961..8f407f9bce 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.c
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c
@@ -42,6 +42,7 @@ mlx5dr_cmd_flow_table_create(struct ibv_context *ctx,
        ft_ctx = MLX5_ADDR_OF(create_flow_table_in, in, flow_table_context);
        MLX5_SET(flow_table_context, ft_ctx, level, ft_attr->level);
        MLX5_SET(flow_table_context, ft_ctx, rtc_valid, ft_attr->rtc_valid);
+       MLX5_SET(flow_table_context, ft_ctx, reformat_en, ft_attr->reformat_en);
 
        devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, 
sizeof(out));
        if (!devx_obj->obj) {
@@ -182,12 +183,24 @@ mlx5dr_cmd_set_fte(struct ibv_context *ctx,
        action_flags = fte_attr->action_flags;
        MLX5_SET(flow_context, in_flow_context, action, action_flags);
 
+       if (action_flags & MLX5_FLOW_CONTEXT_ACTION_REFORMAT)
+               MLX5_SET(flow_context, in_flow_context,
+                        packet_reformat_id, fte_attr->packet_reformat_id);
+
+       if (action_flags & (MLX5_FLOW_CONTEXT_ACTION_DECRYPT | 
MLX5_FLOW_CONTEXT_ACTION_ENCRYPT)) {
+               MLX5_SET(flow_context, in_flow_context,
+                        encrypt_decrypt_type, fte_attr->encrypt_decrypt_type);
+               MLX5_SET(flow_context, in_flow_context,
+                        encrypt_decrypt_obj_id, 
fte_attr->encrypt_decrypt_obj_id);
+       }
+
        if (action_flags & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
                /* Only destination_list_size of size 1 is supported */
                MLX5_SET(flow_context, in_flow_context, destination_list_size, 
1);
                in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, 
destination);
                MLX5_SET(dest_format, in_dests, destination_type, 
fte_attr->destination_type);
                MLX5_SET(dest_format, in_dests, destination_id, 
fte_attr->destination_id);
+               MLX5_SET(set_fte_in, in, ignore_flow_level, 
fte_attr->ignore_flow_level);
        }
 
        devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, 
sizeof(out));
diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.h 
b/drivers/net/mlx5/hws/mlx5dr_cmd.h
index f45b6c6b07..bf3a362300 100644
--- a/drivers/net/mlx5/hws/mlx5dr_cmd.h
+++ b/drivers/net/mlx5/hws/mlx5dr_cmd.h
@@ -7,8 +7,12 @@
 
 struct mlx5dr_cmd_set_fte_attr {
        uint32_t action_flags;
+       uint8_t encrypt_decrypt_type;
+       uint32_t encrypt_decrypt_obj_id;
+       uint32_t packet_reformat_id;
        uint8_t destination_type;
        uint32_t destination_id;
+       uint8_t ignore_flow_level;
        uint8_t flow_source;
 };
 
@@ -16,6 +20,7 @@ struct mlx5dr_cmd_ft_create_attr {
        uint8_t type;
        uint8_t level;
        bool rtc_valid;
+       uint8_t reformat_en;
 };
 
 #define ACCESS_KEY_LEN 32
@@ -296,6 +301,20 @@ struct mlx5dr_devx_obj *
 mlx5dr_cmd_packet_reformat_create(struct ibv_context *ctx,
                                  struct mlx5dr_cmd_packet_reformat_create_attr 
*attr);
 
+struct mlx5dr_devx_obj *
+mlx5dr_cmd_set_fte(struct ibv_context *ctx,
+                  uint32_t table_type,
+                  uint32_t table_id,
+                  uint32_t group_id,
+                  struct mlx5dr_cmd_set_fte_attr *fte_attr);
+
+struct mlx5dr_cmd_forward_tbl *
+mlx5dr_cmd_forward_tbl_create(struct ibv_context *ctx,
+                             struct mlx5dr_cmd_ft_create_attr *ft_attr,
+                             struct mlx5dr_cmd_set_fte_attr *fte_attr);
+
+void mlx5dr_cmd_forward_tbl_destroy(struct mlx5dr_cmd_forward_tbl *tbl);
+
 struct mlx5dr_devx_obj *
 mlx5dr_cmd_alias_obj_create(struct ibv_context *ctx,
                            struct mlx5dr_cmd_alias_obj_create_attr 
*alias_attr);
-- 
2.39.2

Reply via email to