]> git.itanic.dy.fi Git - linux-stable/commitdiff
net/mlx5: DR, Add support for UPLINK destination type
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Sun, 24 Oct 2021 18:36:30 +0000 (21:36 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 31 Dec 2021 08:17:17 +0000 (00:17 -0800)
Add support for a new destination type - UPLINK.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c

index 762b9730a897a0a295886a77cfa72086e0ce958b..dafe341358c7b36183bb380cb7a28819328bd6a5 100644 (file)
@@ -451,7 +451,8 @@ static int mlx5_set_extended_dest(struct mlx5_core_dev *dev,
        list_for_each_entry(dst, &fte->node.children, node.list) {
                if (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER)
                        continue;
-               if (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
+               if ((dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
+                    dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) &&
                    dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID)
                        num_encap++;
                num_fwd_destinations++;
index a8671d7b7ca8b04fb94336d7cc01b2f600e33b96..cc76ceebd2084207d71252b6db970fcd5709950a 100644 (file)
@@ -1525,7 +1525,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
                                struct mlx5_flow_destination *d2)
 {
        if (d1->type == d2->type) {
-               if ((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
+               if (((d1->type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
+                     d1->type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) &&
                     d1->vport.num == d2->vport.num &&
                     d1->vport.flags == d2->vport.flags &&
                     ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ?
index 0d7575b64ca4b2f6520843e98fc41a943f189774..e1a79eb66f3ce604b052d96a1d30fda0df4df659 100644 (file)
@@ -599,7 +599,8 @@ static int mlx5dr_cmd_set_extended_dest(struct mlx5_core_dev *dev,
        for (i = 0; i < fte->dests_size; i++) {
                if (fte->dest_arr[i].type == MLX5_FLOW_DESTINATION_TYPE_COUNTER)
                        continue;
-               if (fte->dest_arr[i].type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
+               if ((fte->dest_arr[i].type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
+                    fte->dest_arr[i].type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) &&
                    fte->dest_arr[i].vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID)
                        num_encap++;
                num_fwd_destinations++;
@@ -724,12 +725,19 @@ int mlx5dr_cmd_set_fte(struct mlx5_core_dev *dev,
                        case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE:
                                id = fte->dest_arr[i].ft_id;
                                break;
+                       case MLX5_FLOW_DESTINATION_TYPE_UPLINK:
                        case MLX5_FLOW_DESTINATION_TYPE_VPORT:
-                               id = fte->dest_arr[i].vport.num;
-                               MLX5_SET(dest_format_struct, in_dests,
-                                        destination_eswitch_owner_vhca_id_valid,
-                                        !!(fte->dest_arr[i].vport.flags &
-                                           MLX5_FLOW_DEST_VPORT_VHCA_ID));
+                               if (type == MLX5_FLOW_DESTINATION_TYPE_VPORT) {
+                                       id = fte->dest_arr[i].vport.num;
+                                       MLX5_SET(dest_format_struct, in_dests,
+                                                destination_eswitch_owner_vhca_id_valid,
+                                                !!(fte->dest_arr[i].vport.flags &
+                                                   MLX5_FLOW_DEST_VPORT_VHCA_ID));
+                               } else {
+                                       id = 0;
+                                       MLX5_SET(dest_format_struct, in_dests,
+                                                destination_eswitch_owner_vhca_id_valid, 1);
+                               }
                                MLX5_SET(dest_format_struct, in_dests,
                                         destination_eswitch_owner_vhca_id,
                                         fte->dest_arr[i].vport.vhca_id);
index 2632d5ae9bc0e0b9c8bcd609d68672e004b80693..a476da2424f8e39d22f6bcac1666a85d10d8b1e9 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 /* Copyright (c) 2019 Mellanox Technologies */
 
+#include <linux/mlx5/vport.h>
 #include "mlx5_core.h"
 #include "fs_core.h"
 #include "fs_cmd.h"
@@ -194,6 +195,15 @@ static struct mlx5dr_action *create_vport_action(struct mlx5dr_domain *domain,
                                               dest_attr->vport.vhca_id);
 }
 
+static struct mlx5dr_action *create_uplink_action(struct mlx5dr_domain *domain,
+                                                 struct mlx5_flow_rule *dst)
+{
+       struct mlx5_flow_destination *dest_attr = &dst->dest_attr;
+
+       return mlx5dr_action_create_dest_vport(domain, MLX5_VPORT_UPLINK, 1,
+                                              dest_attr->vport.vhca_id);
+}
+
 static struct mlx5dr_action *create_ft_action(struct mlx5dr_domain *domain,
                                              struct mlx5_flow_rule *dst)
 {
@@ -218,7 +228,8 @@ static struct mlx5dr_action *create_action_push_vlan(struct mlx5dr_domain *domai
 
 static bool contain_vport_reformat_action(struct mlx5_flow_rule *dst)
 {
-       return dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
+       return (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT ||
+               dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) &&
                dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID;
 }
 
@@ -411,8 +422,11 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
                                fs_dr_actions[fs_dr_num_actions++] = tmp_action;
                                term_actions[num_term_actions++].dest = tmp_action;
                                break;
+                       case MLX5_FLOW_DESTINATION_TYPE_UPLINK:
                        case MLX5_FLOW_DESTINATION_TYPE_VPORT:
-                               tmp_action = create_vport_action(domain, dst);
+                               tmp_action = type == MLX5_FLOW_DESTINATION_TYPE_VPORT ?
+                                            create_vport_action(domain, dst) :
+                                            create_uplink_action(domain, dst);
                                if (!tmp_action) {
                                        err = -ENOMEM;
                                        goto free_actions;