You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmod-redhat-mlx5_core/SOURCES/0081-netdrv-net-mlx5-Move-A...

162 lines
5.4 KiB

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