Blame SOURCES/0081-netdrv-net-mlx5-Move-ACL-drop-counters-life-cycle-cl.patch

d8f823
From 5e82bd06ba83b431da61f9c9b735dd9f427973ec Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Sun, 10 May 2020 15:03:58 -0400
d8f823
Subject: [PATCH 081/312] [netdrv] net/mlx5: Move ACL drop counters life cycle
d8f823
 close to ACL lifecycle
d8f823
d8f823
Message-id: <20200510150452.10307-34-ahleihel@redhat.com>
d8f823
Patchwork-id: 306656
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1789380 v2 33/87] net/mlx5: Move ACL drop counters life cycle close to ACL lifecycle
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 b7752f8341c4fecc4720fbd58f868e114a57fdea
d8f823
Author: Parav Pandit <parav@mellanox.com>
d8f823
Date:   Mon Oct 28 23:35:19 2019 +0000
d8f823
d8f823
    net/mlx5: Move ACL drop counters life cycle close to ACL lifecycle
d8f823
d8f823
    It is better to create/destroy ACL related drop counters where the actual
d8f823
    drop rule ACLs are created/destroyed, so that ACL configuration is self
d8f823
    contained for ingress and egress.
d8f823
d8f823
    Signed-off-by: Parav Pandit <parav@mellanox.com>
d8f823
    Reviewed-by: Vu Pham <vuhuong@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 | 74 +++++++++++------------
d8f823
 1 file changed, 35 insertions(+), 39 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 f854750a15c5..2d094bb7b8a1 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
d8f823
@@ -1660,58 +1660,55 @@ static void esw_apply_vport_conf(struct mlx5_eswitch *esw,
d8f823
 			       flags);
d8f823
 }
d8f823
 
d8f823
-static void esw_legacy_vport_create_drop_counters(struct mlx5_vport *vport)
d8f823
+static int esw_vport_create_legacy_acl_tables(struct mlx5_eswitch *esw,
d8f823
+					      struct mlx5_vport *vport)
d8f823
 {
d8f823
-	struct mlx5_core_dev *dev = vport->dev;
d8f823
+	int ret;
d8f823
 
d8f823
-	if (MLX5_CAP_ESW_INGRESS_ACL(dev, flow_counter)) {
d8f823
-		vport->ingress.legacy.drop_counter = mlx5_fc_create(dev, false);
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
+	if (!mlx5_esw_is_manager_vport(esw, vport->vport) &&
d8f823
+	    MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
d8f823
+		vport->ingress.legacy.drop_counter = mlx5_fc_create(esw->dev, false);
d8f823
 		if (IS_ERR(vport->ingress.legacy.drop_counter)) {
d8f823
-			esw_warn(dev,
d8f823
+			esw_warn(esw->dev,
d8f823
 				 "vport[%d] configure ingress drop rule counter failed\n",
d8f823
 				 vport->vport);
d8f823
 			vport->ingress.legacy.drop_counter = NULL;
d8f823
 		}
d8f823
 	}
d8f823
 
d8f823
-	if (MLX5_CAP_ESW_EGRESS_ACL(dev, flow_counter)) {
d8f823
-		vport->egress.legacy.drop_counter = mlx5_fc_create(dev, false);
d8f823
+	ret = esw_vport_ingress_config(esw, vport);
d8f823
+	if (ret)
d8f823
+		goto ingress_err;
d8f823
+
d8f823
+	if (!mlx5_esw_is_manager_vport(esw, vport->vport) &&
d8f823
+	    MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) {
d8f823
+		vport->egress.legacy.drop_counter = mlx5_fc_create(esw->dev, false);
d8f823
 		if (IS_ERR(vport->egress.legacy.drop_counter)) {
d8f823
-			esw_warn(dev,
d8f823
+			esw_warn(esw->dev,
d8f823
 				 "vport[%d] configure egress drop rule counter failed\n",
d8f823
 				 vport->vport);
d8f823
 			vport->egress.legacy.drop_counter = NULL;
d8f823
 		}
d8f823
 	}
d8f823
-}
d8f823
-
d8f823
-static void esw_legacy_vport_destroy_drop_counters(struct mlx5_vport *vport)
d8f823
-{
d8f823
-	struct mlx5_core_dev *dev = vport->dev;
d8f823
-
d8f823
-	if (vport->ingress.legacy.drop_counter)
d8f823
-		mlx5_fc_destroy(dev, vport->ingress.legacy.drop_counter);
d8f823
-	if (vport->egress.legacy.drop_counter)
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
+		goto egress_err;
d8f823
+
d8f823
+	return 0;
d8f823
 
d8f823
+egress_err:
d8f823
+	esw_vport_disable_ingress_acl(esw, vport);
d8f823
+	mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter);
d8f823
+	vport->egress.legacy.drop_counter = NULL;
d8f823
+
d8f823
+ingress_err:
d8f823
+	mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter);
d8f823
+	vport->ingress.legacy.drop_counter = NULL;
d8f823
 	return ret;
d8f823
 }
d8f823
 
d8f823
@@ -1732,8 +1729,12 @@ static void esw_vport_destroy_legacy_acl_tables(struct mlx5_eswitch *esw,
d8f823
 		return;
d8f823
 
d8f823
 	esw_vport_disable_egress_acl(esw, vport);
d8f823
+	mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter);
d8f823
+	vport->egress.legacy.drop_counter = NULL;
d8f823
+
d8f823
 	esw_vport_disable_ingress_acl(esw, vport);
d8f823
-	esw_legacy_vport_destroy_drop_counters(vport);
d8f823
+	mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter);
d8f823
+	vport->ingress.legacy.drop_counter = NULL;
d8f823
 }
d8f823
 
d8f823
 static void esw_vport_cleanup_acl(struct mlx5_eswitch *esw,
d8f823
@@ -1754,11 +1755,6 @@ static int esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport,
d8f823
 
d8f823
 	esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num);
d8f823
 
d8f823
-	/* Create steering drop counters for ingress and egress ACLs */
d8f823
-	if (!mlx5_esw_is_manager_vport(esw, vport_num) &&
d8f823
-	    esw->mode == MLX5_ESWITCH_LEGACY)
d8f823
-		esw_legacy_vport_create_drop_counters(vport);
d8f823
-
d8f823
 	/* Restore old vport configuration */
d8f823
 	esw_apply_vport_conf(esw, vport);
d8f823
 
d8f823
-- 
d8f823
2.13.6
d8f823