]> git.itanic.dy.fi Git - linux-stable/commitdiff
net/mlx5: DR, Refactor ste_ctx handling for STE v0/1
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Wed, 23 Feb 2022 16:17:39 +0000 (18:17 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 9 Mar 2022 21:33:04 +0000 (13:33 -0800)
As preparation for supporting ConnectX-7, this patches changes handling
of ste_ctx handling for existing STE v0 and V1:
 - each context is now a static struct, and it has a corresponding getter
 - v0 and v1 were extended to contain the fields that are required for
   integrating STEv2.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.h
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h

index c7094fb10a7f444b6e2ed6953c64183d890c9b1d..b25df6ae8ef3cc5cfe987aa0d86f1c64b5aab908 100644 (file)
@@ -523,8 +523,8 @@ void mlx5dr_ste_set_actions_tx(struct mlx5dr_ste_ctx *ste_ctx,
                               struct mlx5dr_ste_actions_attr *attr,
                               u32 *added_stes)
 {
-       ste_ctx->set_actions_tx(dmn, action_type_set, hw_ste_arr,
-                               attr, added_stes);
+       ste_ctx->set_actions_tx(dmn, action_type_set, ste_ctx->actions_caps,
+                               hw_ste_arr, attr, added_stes);
 }
 
 void mlx5dr_ste_set_actions_rx(struct mlx5dr_ste_ctx *ste_ctx,
@@ -534,8 +534,8 @@ void mlx5dr_ste_set_actions_rx(struct mlx5dr_ste_ctx *ste_ctx,
                               struct mlx5dr_ste_actions_attr *attr,
                               u32 *added_stes)
 {
-       ste_ctx->set_actions_rx(dmn, action_type_set, hw_ste_arr,
-                               attr, added_stes);
+       ste_ctx->set_actions_rx(dmn, action_type_set, ste_ctx->actions_caps,
+                               hw_ste_arr, attr, added_stes);
 }
 
 const struct mlx5dr_ste_action_modify_field *
@@ -1361,15 +1361,12 @@ void mlx5dr_ste_build_tnl_header_0_1(struct mlx5dr_ste_ctx *ste_ctx,
        ste_ctx->build_tnl_header_0_1_init(sb, mask);
 }
 
-static struct mlx5dr_ste_ctx *mlx5dr_ste_ctx_arr[] = {
-       [MLX5_STEERING_FORMAT_CONNECTX_5] = &ste_ctx_v0,
-       [MLX5_STEERING_FORMAT_CONNECTX_6DX] = &ste_ctx_v1,
-};
-
 struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx(u8 version)
 {
-       if (version > MLX5_STEERING_FORMAT_CONNECTX_6DX)
-               return NULL;
+       if (version == MLX5_STEERING_FORMAT_CONNECTX_5)
+               return mlx5dr_ste_get_ctx_v0();
+       else if (version == MLX5_STEERING_FORMAT_CONNECTX_6DX)
+               return mlx5dr_ste_get_ctx_v1();
 
-       return mlx5dr_ste_ctx_arr[version];
+       return NULL;
 }
index ca8fa32b8680f97a55a0f96d0e88e2d9f1e5338f..9d9b073df75b6a6b20a7442331dfb52e816daedc 100644 (file)
@@ -161,11 +161,13 @@ struct mlx5dr_ste_ctx {
        u32 actions_caps;
        void (*set_actions_rx)(struct mlx5dr_domain *dmn,
                               u8 *action_type_set,
+                              u32 actions_caps,
                               u8 *hw_ste_arr,
                               struct mlx5dr_ste_actions_attr *attr,
                               u32 *added_stes);
        void (*set_actions_tx)(struct mlx5dr_domain *dmn,
                               u8 *action_type_set,
+                              u32 actions_caps,
                               u8 *hw_ste_arr,
                               struct mlx5dr_ste_actions_attr *attr,
                               u32 *added_stes);
@@ -197,7 +199,7 @@ struct mlx5dr_ste_ctx {
        void (*prepare_for_postsend)(u8 *hw_ste_p, u32 ste_size);
 };
 
-extern struct mlx5dr_ste_ctx ste_ctx_v0;
-extern struct mlx5dr_ste_ctx ste_ctx_v1;
+struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx_v0(void);
+struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx_v1(void);
 
 #endif  /* _DR_STE_ */
index 80424d1e3bb7d5edf95a9756ed1216f8407e4a7e..5a322335f2043d570302fd810ca7f5a06737d80e 100644 (file)
@@ -408,6 +408,7 @@ static void dr_ste_v0_arr_init_next(u8 **last_ste,
 static void
 dr_ste_v0_set_actions_tx(struct mlx5dr_domain *dmn,
                         u8 *action_type_set,
+                        u32 actions_caps,
                         u8 *last_ste,
                         struct mlx5dr_ste_actions_attr *attr,
                         u32 *added_stes)
@@ -477,6 +478,7 @@ dr_ste_v0_set_actions_tx(struct mlx5dr_domain *dmn,
 static void
 dr_ste_v0_set_actions_rx(struct mlx5dr_domain *dmn,
                         u8 *action_type_set,
+                        u32 actions_caps,
                         u8 *last_ste,
                         struct mlx5dr_ste_actions_attr *attr,
                         u32 *added_stes)
@@ -1898,7 +1900,7 @@ static void dr_ste_v0_build_tnl_header_0_1_init(struct mlx5dr_ste_build *sb,
        sb->ste_build_tag_func = &dr_ste_v0_build_tnl_header_0_1_tag;
 }
 
-struct mlx5dr_ste_ctx ste_ctx_v0 = {
+static struct mlx5dr_ste_ctx ste_ctx_v0 = {
        /* Builders */
        .build_eth_l2_src_dst_init      = &dr_ste_v0_build_eth_l2_src_dst_init,
        .build_eth_l3_ipv6_src_init     = &dr_ste_v0_build_eth_l3_ipv6_src_init,
@@ -1951,3 +1953,8 @@ struct mlx5dr_ste_ctx ste_ctx_v0 = {
        .set_action_copy                = &dr_ste_v0_set_action_copy,
        .set_action_decap_l3_list       = &dr_ste_v0_set_action_decap_l3_list,
 };
+
+struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx_v0(void)
+{
+       return &ste_ctx_v0;
+}
index 4a7b038dd15d39ab7f77f7cf2e8922a1e88e8ad3..2f6d0d62874f3742a6a08f3c2d7dca0b3c151ea1 100644 (file)
@@ -513,6 +513,7 @@ static void dr_ste_v1_arr_init_next_match(u8 **last_ste,
 
 static void dr_ste_v1_set_actions_tx(struct mlx5dr_domain *dmn,
                                     u8 *action_type_set,
+                                    u32 actions_caps,
                                     u8 *last_ste,
                                     struct mlx5dr_ste_actions_attr *attr,
                                     u32 *added_stes)
@@ -533,6 +534,10 @@ static void dr_ste_v1_set_actions_tx(struct mlx5dr_domain *dmn,
                dr_ste_v1_set_pop_vlan(last_ste, action, attr->vlans.count);
                action_sz -= DR_STE_ACTION_SINGLE_SZ;
                action += DR_STE_ACTION_SINGLE_SZ;
+
+               /* Check if vlan_pop and modify_hdr on same STE is supported */
+               if (!(actions_caps & DR_STE_CTX_ACTION_CAP_POP_MDFY))
+                       allow_modify_hdr = false;
        }
 
        if (action_type_set[DR_ACTION_TYP_CTR])
@@ -632,6 +637,7 @@ static void dr_ste_v1_set_actions_tx(struct mlx5dr_domain *dmn,
 
 static void dr_ste_v1_set_actions_rx(struct mlx5dr_domain *dmn,
                                     u8 *action_type_set,
+                                    u32 actions_caps,
                                     u8 *last_ste,
                                     struct mlx5dr_ste_actions_attr *attr,
                                     u32 *added_stes)
@@ -682,6 +688,10 @@ static void dr_ste_v1_set_actions_rx(struct mlx5dr_domain *dmn,
                action_sz -= DR_STE_ACTION_SINGLE_SZ;
                action += DR_STE_ACTION_SINGLE_SZ;
                allow_ctr = false;
+
+               /* Check if vlan_pop and modify_hdr on same STE is supported */
+               if (!(actions_caps & DR_STE_CTX_ACTION_CAP_POP_MDFY))
+                       allow_modify_hdr = false;
        }
 
        if (action_type_set[DR_ACTION_TYP_MODIFY_HDR]) {
@@ -2045,7 +2055,7 @@ dr_ste_v1_build_tnl_gtpu_flex_parser_1_init(struct mlx5dr_ste_build *sb,
        sb->ste_build_tag_func = &dr_ste_v1_build_tnl_gtpu_flex_parser_1_tag;
 }
 
-struct mlx5dr_ste_ctx ste_ctx_v1 = {
+static struct mlx5dr_ste_ctx ste_ctx_v1 = {
        /* Builders */
        .build_eth_l2_src_dst_init      = &dr_ste_v1_build_eth_l2_src_dst_init,
        .build_eth_l3_ipv6_src_init     = &dr_ste_v1_build_eth_l3_ipv6_src_init,
@@ -2090,7 +2100,8 @@ struct mlx5dr_ste_ctx ste_ctx_v1 = {
        /* Actions */
        .actions_caps                   = DR_STE_CTX_ACTION_CAP_TX_POP |
                                          DR_STE_CTX_ACTION_CAP_RX_PUSH |
-                                         DR_STE_CTX_ACTION_CAP_RX_ENCAP,
+                                         DR_STE_CTX_ACTION_CAP_RX_ENCAP |
+                                         DR_STE_CTX_ACTION_CAP_POP_MDFY,
        .set_actions_rx                 = &dr_ste_v1_set_actions_rx,
        .set_actions_tx                 = &dr_ste_v1_set_actions_tx,
        .modify_field_arr_sz            = ARRAY_SIZE(dr_ste_v1_action_modify_field_arr),
@@ -2102,3 +2113,8 @@ struct mlx5dr_ste_ctx ste_ctx_v1 = {
        /* Send */
        .prepare_for_postsend           = &dr_ste_v1_prepare_for_postsend,
 };
+
+struct mlx5dr_ste_ctx *mlx5dr_ste_get_ctx_v1(void)
+{
+       return &ste_ctx_v1;
+}
index 02590f6651744e9549d79a85c9cfc4caae2e04c5..88092fabf55b3b22a1f426172ec5fef15b0a6f53 100644 (file)
@@ -91,6 +91,7 @@ enum mlx5dr_ste_ctx_action_cap {
        DR_STE_CTX_ACTION_CAP_TX_POP   = 1 << 0,
        DR_STE_CTX_ACTION_CAP_RX_PUSH  = 1 << 1,
        DR_STE_CTX_ACTION_CAP_RX_ENCAP = 1 << 2,
+       DR_STE_CTX_ACTION_CAP_POP_MDFY = 1 << 3,
 };
 
 enum {