Blob Blame History Raw
From 1ee524cc59988f1b56d8bc6f1f49ba56223852fe Mon Sep 17 00:00:00 2001
From: Ivan Vecera <ivecera@redhat.com>
Date: Fri, 27 Mar 2020 19:44:24 -0400
Subject: [PATCH 004/312] [netdrv] mlx5e: Reorder mirrer action parsing to
 check for encap first

Message-id: <20200327194424.1643094-20-ivecera@redhat.com>
Patchwork-id: 298090
Patchwork-instance: patchwork
O-Subject: [RHEL-8.3 net PATCH 19/19] net/mlx5e: Reorder mirrer action parsing to check for encap first
Bugzilla: 1818074
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
RH-Acked-by: John Linville <linville@redhat.com>
RH-Acked-by: Petr Oros <poros@redhat.com>

Bugzilla: http://bugzilla.redhat.com/show_bug.cgi?id=1818074

Upstream commit(s):
commit b6a4ac24c14be1247b0fd896737a01b8fa121318
Author: Vlad Buslov <vladbu@mellanox.com>
Date:   Thu Nov 7 13:37:57 2019 +0200

    net/mlx5e: Reorder mirrer action parsing to check for encap first

    Mirred action parsing code in parse_tc_fdb_actions() first checks if
    out_dev has same parent id, and only verifies that there is a pending encap
    action that was parsed before. Recent change in vxlan module made function
    netdev_port_same_parent_id() to return true when called for mlx5 eswitch
    representor and vxlan device created explicitly on mlx5 representor
    device (vxlan devices created with "external" flag without explicitly
    specifying parent interface are not affected). With call to
    netdev_port_same_parent_id() returning true, incorrect code path is chosen
    and encap rules fail to offload because vxlan dev is not a valid eswitch
    forwarding dev. Dmesg log of error:

    [ 1784.389797] devices ens1f0_0 vxlan1 not on same switch HW, can't offload forwarding

    In order to fix the issue, rearrange conditional in parse_tc_fdb_actions()
    to check for pending encap action before checking if out_dev has the same
    parent id.

    Fixes: 0ce1822c2a08 ("vxlan: add adjacent link to limit depth level")
    Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
    Reviewed-by: Roi Dayan <roid@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 28 ++++++++++++-------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index db960e3ea3cd..f06e99eb06b9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3270,7 +3270,20 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 
 			action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
 				  MLX5_FLOW_CONTEXT_ACTION_COUNT;
-			if (netdev_port_same_parent_id(priv->netdev, out_dev)) {
+			if (encap) {
+				parse_attr->mirred_ifindex[attr->out_count] =
+					out_dev->ifindex;
+				parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
+				if (!parse_attr->tun_info[attr->out_count])
+					return -ENOMEM;
+				encap = false;
+				attr->dests[attr->out_count].flags |=
+					MLX5_ESW_DEST_ENCAP;
+				attr->out_count++;
+				/* attr->dests[].rep is resolved when we
+				 * handle encap
+				 */
+			} else if (netdev_port_same_parent_id(priv->netdev, out_dev)) {
 				struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
 				struct net_device *uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);
 				struct net_device *uplink_upper;
@@ -3312,19 +3325,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 				attr->dests[attr->out_count].rep = rpriv->rep;
 				attr->dests[attr->out_count].mdev = out_priv->mdev;
 				attr->out_count++;
-			} else if (encap) {
-				parse_attr->mirred_ifindex[attr->out_count] =
-					out_dev->ifindex;
-				parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
-				if (!parse_attr->tun_info[attr->out_count])
-					return -ENOMEM;
-				encap = false;
-				attr->dests[attr->out_count].flags |=
-					MLX5_ESW_DEST_ENCAP;
-				attr->out_count++;
-				/* attr->dests[].rep is resolved when we
-				 * handle encap
-				 */
 			} else if (parse_attr->filter_dev != priv->netdev) {
 				/* All mlx5 devices are called to configure
 				 * high level device filters. Therefore, the
-- 
2.13.6