net/mlx5: DR, Handle multi destination action in the right order
authorErez Shitrit <erezsh@nvidia.com>
Mon, 28 Aug 2023 11:37:12 +0000 (14:37 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 20 Sep 2023 06:33:08 +0000 (23:33 -0700)
Whenever we have few destinations from Flow-table type we need to put
the one that goes to the wire to be the last one.

We are using FW in order to get iterator, the FW uses RX for the first
destinations and TX for the last destination, if we want the packet to
be directed to the wire it should be done in the TX path and not in the
RX.
The code now checks if the FT is directed to the wire and if so puts it
as the last destination.

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c

index 7179542e9164018365b2159122fe923f995171fc..6ea88a5818047224973f7eb76e6beeebaf55b7f9 100644 (file)
@@ -1169,13 +1169,16 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
                                   bool ignore_flow_level,
                                   u32 flow_source)
 {
+       struct mlx5dr_cmd_flow_destination_hw_info tmp_hw_dest;
        struct mlx5dr_cmd_flow_destination_hw_info *hw_dests;
        struct mlx5dr_action **ref_actions;
        struct mlx5dr_action *action;
        bool reformat_req = false;
+       bool is_ft_wire = false;
        u16 num_dst_ft = 0;
        u32 num_of_ref = 0;
        u32 ref_act_cnt;
+       u16 last_dest;
        int ret;
        int i;
 
@@ -1224,10 +1227,15 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
                        }
                        num_dst_ft++;
                        hw_dests[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
-                       if (dest_action->dest_tbl->is_fw_tbl)
+                       if (dest_action->dest_tbl->is_fw_tbl) {
                                hw_dests[i].ft_id = dest_action->dest_tbl->fw_tbl.id;
-                       else
+                       } else {
                                hw_dests[i].ft_id = dest_action->dest_tbl->tbl->table_id;
+                               if (dest_action->dest_tbl->is_wire_ft) {
+                                       is_ft_wire = true;
+                                       last_dest = i;
+                               }
+                       }
                        break;
 
                default:
@@ -1236,6 +1244,16 @@ mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
                }
        }
 
+       /* In multidest, the FW does the iterator in the RX except of the last
+        * one that done in the TX.
+        * So, if one of the ft target is wire, put it at the end of the dest list.
+        */
+       if (is_ft_wire && num_dst_ft > 1) {
+               tmp_hw_dest = hw_dests[last_dest];
+               hw_dests[last_dest] = hw_dests[num_of_dests - 1];
+               hw_dests[num_of_dests - 1] = tmp_hw_dest;
+       }
+
        action = dr_action_create_generic(DR_ACTION_TYP_FT);
        if (!action)
                goto free_ref_actions;
index 6c59de3e28f6568fb16ec76287ca99b8b1da3733..55dc7383477c9c45fb0d74c8d54103f5616c116a 100644 (file)
@@ -1064,6 +1064,7 @@ struct mlx5dr_action_sampler {
 
 struct mlx5dr_action_dest_tbl {
        u8 is_fw_tbl:1;
+       u8 is_wire_ft:1;
        union {
                struct mlx5dr_table *tbl;
                struct {
index 14f6df88b1f9a6712084552a055b5e0c70754b92..50c2554c9ccf24eb8a0e67b79a424ed0b82c4fcf 100644 (file)
@@ -209,10 +209,17 @@ static struct mlx5dr_action *create_ft_action(struct mlx5dr_domain *domain,
                                              struct mlx5_flow_rule *dst)
 {
        struct mlx5_flow_table *dest_ft = dst->dest_attr.ft;
+       struct mlx5dr_action *tbl_action;
 
        if (mlx5dr_is_fw_table(dest_ft))
                return mlx5dr_action_create_dest_flow_fw_table(domain, dest_ft);
-       return mlx5dr_action_create_dest_table(dest_ft->fs_dr_table.dr_table);
+
+       tbl_action = mlx5dr_action_create_dest_table(dest_ft->fs_dr_table.dr_table);
+       if (tbl_action)
+               tbl_action->dest_tbl->is_wire_ft =
+                       dest_ft->flags & MLX5_FLOW_TABLE_UPLINK_VPORT ? 1 : 0;
+
+       return tbl_action;
 }
 
 static struct mlx5dr_action *create_range_action(struct mlx5dr_domain *domain,