Blame SOURCES/0080-netdrv-net-mlx5-E-switch-Legacy-introduce-and-use-pe.patch

d8f823
From 13d9574432dadefa6a706a4d523082b56bb4d200 Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Sun, 10 May 2020 15:03:57 -0400
d8f823
Subject: [PATCH 080/312] [netdrv] net/mlx5: E-switch, Legacy introduce and use
d8f823
 per vport acl tables APIs
d8f823
d8f823
Message-id: <20200510150452.10307-33-ahleihel@redhat.com>
d8f823
Patchwork-id: 306657
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1789380 v2 32/87] net/mlx5: E-switch, Legacy introduce and use per vport acl tables APIs
d8f823
Bugzilla: 1789380
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Jonathan Toppins <jtoppins@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1789380
d8f823
Upstream: v5.5-rc1
d8f823
d8f823
commit f5d0c01d65adba2b898836894d200e85c8a8def3
d8f823
Author: Parav Pandit <parav@mellanox.com>
d8f823
Date:   Mon Oct 28 23:35:17 2019 +0000
d8f823
d8f823
    net/mlx5: E-switch, Legacy introduce and use per vport acl tables APIs
d8f823
d8f823
    Introduce and use per vport ACL tables creation and destroy APIs, so that
d8f823
    subsequently patch can use them during enabling/disabling a vport in
d8f823
    unified way for legacy vs offloads mode.
d8f823
d8f823
    Signed-off-by: Parav Pandit <parav@mellanox.com>
d8f823
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 73 +++++++++++++++++++----
d8f823
 1 file changed, 60 insertions(+), 13 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
d8f823
index 2ecb993545f9..f854750a15c5 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
d8f823
@@ -1658,12 +1658,6 @@ static void esw_apply_vport_conf(struct mlx5_eswitch *esw,
d8f823
 		SET_VLAN_STRIP | SET_VLAN_INSERT : 0;
d8f823
 	modify_esw_vport_cvlan(esw->dev, vport_num, vport->info.vlan, vport->info.qos,
d8f823
 			       flags);
d8f823
-
d8f823
-	/* Only legacy mode needs ACLs */
d8f823
-	if (esw->mode == MLX5_ESWITCH_LEGACY) {
d8f823
-		esw_vport_ingress_config(esw, vport);
d8f823
-		esw_vport_egress_config(esw, vport);
d8f823
-	}
d8f823
 }
d8f823
 
d8f823
 static void esw_legacy_vport_create_drop_counters(struct mlx5_vport *vport)
d8f823
@@ -1701,10 +1695,59 @@ static void esw_legacy_vport_destroy_drop_counters(struct mlx5_vport *vport)
d8f823
 		mlx5_fc_destroy(dev, vport->egress.legacy.drop_counter);
d8f823
 }
d8f823
 
d8f823
+static int esw_vport_create_legacy_acl_tables(struct mlx5_eswitch *esw,
d8f823
+					      struct mlx5_vport *vport)
d8f823
+{
d8f823
+	int ret;
d8f823
+
d8f823
+	/* Only non manager vports need ACL in legacy mode */
d8f823
+	if (mlx5_esw_is_manager_vport(esw, vport->vport))
d8f823
+		return 0;
d8f823
+
d8f823
+	ret = esw_vport_ingress_config(esw, vport);
d8f823
+	if (ret)
d8f823
+		return ret;
d8f823
+
d8f823
+	ret = esw_vport_egress_config(esw, vport);
d8f823
+	if (ret)
d8f823
+		esw_vport_disable_ingress_acl(esw, vport);
d8f823
+
d8f823
+	return ret;
d8f823
+}
d8f823
+
d8f823
+static int esw_vport_setup_acl(struct mlx5_eswitch *esw,
d8f823
+			       struct mlx5_vport *vport)
d8f823
+{
d8f823
+	if (esw->mode == MLX5_ESWITCH_LEGACY)
d8f823
+		return esw_vport_create_legacy_acl_tables(esw, vport);
d8f823
+
d8f823
+	return 0;
d8f823
+}
d8f823
+
d8f823
+static void esw_vport_destroy_legacy_acl_tables(struct mlx5_eswitch *esw,
d8f823
+						struct mlx5_vport *vport)
d8f823
+
d8f823
+{
d8f823
+	if (mlx5_esw_is_manager_vport(esw, vport->vport))
d8f823
+		return;
d8f823
+
d8f823
+	esw_vport_disable_egress_acl(esw, vport);
d8f823
+	esw_vport_disable_ingress_acl(esw, vport);
d8f823
+	esw_legacy_vport_destroy_drop_counters(vport);
d8f823
+}
d8f823
+
d8f823
+static void esw_vport_cleanup_acl(struct mlx5_eswitch *esw,
d8f823
+				  struct mlx5_vport *vport)
d8f823
+{
d8f823
+	if (esw->mode == MLX5_ESWITCH_LEGACY)
d8f823
+		esw_vport_destroy_legacy_acl_tables(esw, vport);
d8f823
+}
d8f823
+
d8f823
 static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
d8f823
 			    enum mlx5_eswitch_vport_event enabled_events)
d8f823
 {
d8f823
 	u16 vport_num = vport->vport;
d8f823
+	int ret;
d8f823
 
d8f823
 	mutex_lock(&esw->state_lock);
d8f823
 	WARN_ON(vport->enabled);
d8f823
@@ -1719,6 +1762,10 @@ static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
d8f823
 	/* Restore old vport configuration */
d8f823
 	esw_apply_vport_conf(esw, vport);
d8f823
 
d8f823
+	ret = esw_vport_setup_acl(esw, vport);
d8f823
+	if (ret)
d8f823
+		goto done;
d8f823
+
d8f823
 	/* Attach vport to the eswitch rate limiter */
d8f823
 	if (esw_vport_enable_qos(esw, vport, vport->info.max_rate,
d8f823
 				 vport->qos.bw_share))
d8f823
@@ -1739,8 +1786,9 @@ static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
d8f823
 
d8f823
 	esw->enabled_vports++;
d8f823
 	esw_debug(esw->dev, "Enabled VPORT(%d)\n", vport_num);
d8f823
+done:
d8f823
 	mutex_unlock(&esw->state_lock);
d8f823
-	return 0;
d8f823
+	return ret;
d8f823
 }
d8f823
 
d8f823
 static void esw_disable_vport(struct mlx5_eswitch *esw,
d8f823
@@ -1765,16 +1813,15 @@ static void esw_disable_vport(struct mlx5_eswitch *esw,
d8f823
 	esw_vport_change_handle_locked(vport);
d8f823
 	vport->enabled_events = 0;
d8f823
 	esw_vport_disable_qos(esw, vport);
d8f823
-	if (!mlx5_esw_is_manager_vport(esw, vport_num) &&
d8f823
-	    esw->mode == MLX5_ESWITCH_LEGACY) {
d8f823
+
d8f823
+	if (!mlx5_esw_is_manager_vport(esw, vport->vport) &&
d8f823
+	    esw->mode == MLX5_ESWITCH_LEGACY)
d8f823
 		mlx5_modify_vport_admin_state(esw->dev,
d8f823
 					      MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
d8f823
 					      vport_num, 1,
d8f823
 					      MLX5_VPORT_ADMIN_STATE_DOWN);
d8f823
-		esw_vport_disable_egress_acl(esw, vport);
d8f823
-		esw_vport_disable_ingress_acl(esw, vport);
d8f823
-		esw_legacy_vport_destroy_drop_counters(vport);
d8f823
-	}
d8f823
+
d8f823
+	esw_vport_cleanup_acl(esw, vport);
d8f823
 	esw->enabled_vports--;
d8f823
 
d8f823
 done:
d8f823
-- 
d8f823
2.13.6
d8f823