From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>, Mark Bloch <mbloch@nvidia.com>
Subject: [net-next 13/15] net/mlx5: SRIOV, Recreate egress ACL table on config change
Date: Sat, 3 Dec 2022 14:13:35 -0800 [thread overview]
Message-ID: <20221203221337.29267-14-saeed@kernel.org> (raw)
In-Reply-To: <20221203221337.29267-1-saeed@kernel.org>
From: Moshe Shemesh <moshe@nvidia.com>
The egress ACL table has flow group for cvlan and flow group for drop.
A downstream patch will add also svlan flow steering rule and so will
need a flow group for svlan. Recreating the egress ACL table enables us
to keep one group for allowed traffic, either cvlan or svlan and one
group for drop traffic, similar to the ingress ACL table.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../mellanox/mlx5/core/esw/acl/egress_lgcy.c | 82 ++++++++++---------
.../mellanox/mlx5/core/esw/acl/lgcy.h | 4 +
.../ethernet/mellanox/mlx5/core/esw/legacy.c | 3 +
3 files changed, 52 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c
index 60a73990017c..83ecad5ea80b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c
@@ -69,8 +69,8 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw,
{
struct mlx5_flow_destination drop_ctr_dst = {};
struct mlx5_flow_destination *dst = NULL;
- struct mlx5_fc *drop_counter = NULL;
struct mlx5_flow_act flow_act = {};
+ struct mlx5_fc *drop_counter;
/* The egress acl table contains 2 rules:
* 1)Allow traffic with vlan_tag=vst_vlan_id
* 2)Drop all other traffic.
@@ -79,41 +79,23 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw,
int dest_num = 0;
int err = 0;
- if (vport->egress.legacy.drop_counter) {
- drop_counter = vport->egress.legacy.drop_counter;
- } else if (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) {
- drop_counter = mlx5_fc_create(esw->dev, false);
- if (IS_ERR(drop_counter)) {
- esw_warn(esw->dev,
- "vport[%d] configure egress drop rule counter err(%ld)\n",
- vport->vport, PTR_ERR(drop_counter));
- drop_counter = NULL;
- }
- vport->egress.legacy.drop_counter = drop_counter;
- }
-
- esw_acl_egress_lgcy_rules_destroy(vport);
-
- if (!vport->info.vlan && !vport->info.qos) {
- esw_acl_egress_lgcy_cleanup(esw, vport);
+ esw_acl_egress_lgcy_cleanup(esw, vport);
+ if (!vport->info.vlan && !vport->info.qos)
return 0;
- }
- if (!vport->egress.acl) {
- vport->egress.acl = esw_acl_table_create(esw, vport,
- MLX5_FLOW_NAMESPACE_ESW_EGRESS,
- table_size);
- if (IS_ERR(vport->egress.acl)) {
- err = PTR_ERR(vport->egress.acl);
- vport->egress.acl = NULL;
- goto out;
- }
-
- err = esw_acl_egress_lgcy_groups_create(esw, vport);
- if (err)
- goto out;
+ vport->egress.acl = esw_acl_table_create(esw, vport,
+ MLX5_FLOW_NAMESPACE_ESW_EGRESS,
+ table_size);
+ if (IS_ERR(vport->egress.acl)) {
+ err = PTR_ERR(vport->egress.acl);
+ vport->egress.acl = NULL;
+ goto out;
}
+ err = esw_acl_egress_lgcy_groups_create(esw, vport);
+ if (err)
+ goto out;
+
esw_debug(esw->dev,
"vport[%d] configure egress rules, vlan(%d) qos(%d)\n",
vport->vport, vport->info.vlan, vport->info.qos);
@@ -127,6 +109,7 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw,
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
/* Attach egress drop flow counter */
+ drop_counter = vport->egress.legacy.drop_counter;
if (drop_counter) {
flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_COUNT;
drop_ctr_dst.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
@@ -157,17 +140,42 @@ void esw_acl_egress_lgcy_cleanup(struct mlx5_eswitch *esw,
struct mlx5_vport *vport)
{
if (IS_ERR_OR_NULL(vport->egress.acl))
- goto clean_drop_counter;
+ return;
esw_debug(esw->dev, "Destroy vport[%d] E-Switch egress ACL\n", vport->vport);
esw_acl_egress_lgcy_rules_destroy(vport);
esw_acl_egress_lgcy_groups_destroy(vport);
esw_acl_egress_table_destroy(vport);
+}
-clean_drop_counter:
- if (vport->egress.legacy.drop_counter) {
- mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter);
- vport->egress.legacy.drop_counter = NULL;
+void esw_acl_egress_lgcy_create_counter(struct mlx5_eswitch *esw,
+ struct mlx5_vport *vport)
+{
+ struct mlx5_fc *counter;
+
+ vport->egress.legacy.drop_counter = NULL;
+
+ if (!MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter))
+ return;
+
+ counter = mlx5_fc_create(esw->dev, false);
+ if (IS_ERR(counter)) {
+ esw_warn(esw->dev,
+ "vport[%d] configure egress drop rule counter failed\n",
+ vport->vport);
+ return;
}
+
+ vport->egress.legacy.drop_counter = counter;
+}
+
+void esw_acl_egress_lgcy_destroy_counter(struct mlx5_eswitch *esw,
+ struct mlx5_vport *vport)
+{
+ if (!vport->egress.legacy.drop_counter)
+ return;
+
+ mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter);
+ vport->egress.legacy.drop_counter = NULL;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/lgcy.h b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/lgcy.h
index c4a624ffca43..aa5523eb0abd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/lgcy.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/lgcy.h
@@ -9,6 +9,10 @@
/* Eswitch acl egress external APIs */
int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport);
void esw_acl_egress_lgcy_cleanup(struct mlx5_eswitch *esw, struct mlx5_vport *vport);
+void esw_acl_egress_lgcy_create_counter(struct mlx5_eswitch *esw,
+ struct mlx5_vport *vport);
+void esw_acl_egress_lgcy_destroy_counter(struct mlx5_eswitch *esw,
+ struct mlx5_vport *vport);
/* Eswitch acl ingress external APIs */
int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c
index 97a104668723..bddf1086d771 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/legacy.c
@@ -361,6 +361,7 @@ int esw_legacy_vport_acl_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vpor
if (ret)
goto ingress_err;
+ esw_acl_egress_lgcy_create_counter(esw, vport);
ret = esw_acl_egress_lgcy_setup(esw, vport);
if (ret)
goto egress_err;
@@ -368,6 +369,7 @@ int esw_legacy_vport_acl_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vpor
return 0;
egress_err:
+ esw_acl_egress_lgcy_destroy_counter(esw, vport);
esw_acl_ingress_lgcy_cleanup(esw, vport);
ingress_err:
esw_acl_ingress_lgcy_destroy_counter(esw, vport);
@@ -380,6 +382,7 @@ void esw_legacy_vport_acl_cleanup(struct mlx5_eswitch *esw, struct mlx5_vport *v
return;
esw_acl_egress_lgcy_cleanup(esw, vport);
+ esw_acl_egress_lgcy_destroy_counter(esw, vport);
esw_acl_ingress_lgcy_cleanup(esw, vport);
esw_acl_ingress_lgcy_destroy_counter(esw, vport);
}
--
2.38.1
next prev parent reply other threads:[~2022-12-03 22:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-03 22:13 [pull request][net-next 00/15] mlx5 updates 2022-12-03 Saeed Mahameed
2022-12-03 22:13 ` [net-next 01/15] net/mlx5e: E-Switch, handle flow attribute with no destinations Saeed Mahameed
2022-12-03 22:13 ` [net-next 02/15] net/mlx5: fs, assert null dest pointer when dest_num is 0 Saeed Mahameed
2022-12-03 22:13 ` [net-next 03/15] net/mlx5e: TC, reuse flow attribute post parser processing Saeed Mahameed
2022-12-03 22:13 ` [net-next 04/15] net/mlx5e: TC, add terminating actions Saeed Mahameed
2022-12-03 22:13 ` [net-next 05/15] net/mlx5e: TC, validate action list per attribute Saeed Mahameed
2022-12-03 22:13 ` [net-next 06/15] net/mlx5e: TC, set control params for branching actions Saeed Mahameed
2022-12-03 22:13 ` [net-next 07/15] net/mlx5e: TC, initialize branch flow attributes Saeed Mahameed
2022-12-03 22:13 ` [net-next 08/15] net/mlx5e: TC, initialize branching action with target attr Saeed Mahameed
2022-12-03 22:13 ` [net-next 09/15] net/mlx5e: TC, rename post_meter actions Saeed Mahameed
2022-12-03 22:13 ` [net-next 10/15] net/mlx5e: TC, init post meter rules with branching attributes Saeed Mahameed
2022-12-03 22:13 ` [net-next 11/15] net/mlx5e: TC, allow meter jump control action Saeed Mahameed
2022-12-03 22:13 ` [net-next 12/15] net/mlx5: SRIOV, Remove two unused ingress flow group Saeed Mahameed
2022-12-03 22:13 ` Saeed Mahameed [this message]
2022-12-03 22:13 ` [net-next 14/15] net/mlx5: SRIOV, Add 802.1ad VST support Saeed Mahameed
2022-12-07 4:34 ` Jakub Kicinski
2022-12-07 5:20 ` Saeed Mahameed
2022-12-07 17:25 ` Jakub Kicinski
2022-12-08 8:28 ` Saeed Mahameed
2022-12-09 1:04 ` Jakub Kicinski
2022-12-09 1:57 ` Saeed Mahameed
2022-12-09 2:04 ` Jakub Kicinski
2022-12-09 5:05 ` Saeed Mahameed
2022-12-09 16:34 ` Jakub Kicinski
2022-12-03 22:13 ` [net-next 15/15] net/mlx5: SRIOV, Allow ingress tagged packets on VST Saeed Mahameed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221203221337.29267-14-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).