|
|
d8f823 |
From 3f285c020ca420cf7657c4a51da96573ae038f06 Mon Sep 17 00:00:00 2001
|
|
|
d8f823 |
From: Alaa Hleihel <ahleihel@redhat.com>
|
|
|
d8f823 |
Date: Sun, 10 May 2020 15:03:51 -0400
|
|
|
d8f823 |
Subject: [PATCH 074/312] [netdrv] net/mlx5: E-switch, Introduce and use vlan
|
|
|
d8f823 |
rule config helper
|
|
|
d8f823 |
|
|
|
d8f823 |
Message-id: <20200510150452.10307-27-ahleihel@redhat.com>
|
|
|
d8f823 |
Patchwork-id: 306650
|
|
|
d8f823 |
Patchwork-instance: patchwork
|
|
|
d8f823 |
O-Subject: [RHEL8.3 BZ 1789380 v2 26/87] net/mlx5: E-switch, Introduce and use vlan rule config helper
|
|
|
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 fdde49e00b9d2041086568b52670043a8def96ff
|
|
|
d8f823 |
Author: Parav Pandit <parav@mellanox.com>
|
|
|
d8f823 |
Date: Mon Oct 28 23:35:03 2019 +0000
|
|
|
d8f823 |
|
|
|
d8f823 |
net/mlx5: E-switch, Introduce and use vlan rule config helper
|
|
|
d8f823 |
|
|
|
d8f823 |
Between legacy mode and switchdev mode, only two fields are changed,
|
|
|
d8f823 |
vlan_tag and flow action.
|
|
|
d8f823 |
Hence to avoid duplicte code between two modes, introduce and and use
|
|
|
d8f823 |
helper function to configure allowed VLAN rule.
|
|
|
d8f823 |
|
|
|
d8f823 |
While at it, get rid of duplicate debug message.
|
|
|
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 | 68 ++++++++++++++--------
|
|
|
d8f823 |
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 4 ++
|
|
|
d8f823 |
.../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 54 ++++-------------
|
|
|
d8f823 |
3 files changed, 58 insertions(+), 68 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 386e82850ed5..773246f8e9c4 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
|
|
|
d8f823 |
@@ -1323,6 +1323,43 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
return err;
|
|
|
d8f823 |
}
|
|
|
d8f823 |
|
|
|
d8f823 |
+int mlx5_esw_create_vport_egress_acl_vlan(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
+ struct mlx5_vport *vport,
|
|
|
d8f823 |
+ u16 vlan_id, u32 flow_action)
|
|
|
d8f823 |
+{
|
|
|
d8f823 |
+ struct mlx5_flow_act flow_act = {};
|
|
|
d8f823 |
+ struct mlx5_flow_spec *spec;
|
|
|
d8f823 |
+ int err = 0;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ if (vport->egress.allowed_vlan)
|
|
|
d8f823 |
+ return -EEXIST;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
|
|
|
d8f823 |
+ if (!spec)
|
|
|
d8f823 |
+ return -ENOMEM;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.cvlan_tag);
|
|
|
d8f823 |
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_value, outer_headers.cvlan_tag);
|
|
|
d8f823 |
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.first_vid);
|
|
|
d8f823 |
+ MLX5_SET(fte_match_param, spec->match_value, outer_headers.first_vid, vlan_id);
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
|
|
|
d8f823 |
+ flow_act.action = flow_action;
|
|
|
d8f823 |
+ vport->egress.allowed_vlan =
|
|
|
d8f823 |
+ mlx5_add_flow_rules(vport->egress.acl, spec,
|
|
|
d8f823 |
+ &flow_act, NULL, 0);
|
|
|
d8f823 |
+ if (IS_ERR(vport->egress.allowed_vlan)) {
|
|
|
d8f823 |
+ err = PTR_ERR(vport->egress.allowed_vlan);
|
|
|
d8f823 |
+ esw_warn(esw->dev,
|
|
|
d8f823 |
+ "vport[%d] configure egress vlan rule failed, err(%d)\n",
|
|
|
d8f823 |
+ vport->vport, err);
|
|
|
d8f823 |
+ vport->egress.allowed_vlan = NULL;
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ kvfree(spec);
|
|
|
d8f823 |
+ return err;
|
|
|
d8f823 |
+}
|
|
|
d8f823 |
+
|
|
|
d8f823 |
static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
struct mlx5_vport *vport)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
@@ -1353,34 +1390,17 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
"vport[%d] configure egress rules, vlan(%d) qos(%d)\n",
|
|
|
d8f823 |
vport->vport, vport->info.vlan, vport->info.qos);
|
|
|
d8f823 |
|
|
|
d8f823 |
- spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
|
|
|
d8f823 |
- if (!spec) {
|
|
|
d8f823 |
- err = -ENOMEM;
|
|
|
d8f823 |
- goto out;
|
|
|
d8f823 |
- }
|
|
|
d8f823 |
-
|
|
|
d8f823 |
/* Allowed vlan rule */
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.cvlan_tag);
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_value, outer_headers.cvlan_tag);
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.first_vid);
|
|
|
d8f823 |
- MLX5_SET(fte_match_param, spec->match_value, outer_headers.first_vid, vport->info.vlan);
|
|
|
d8f823 |
+ err = mlx5_esw_create_vport_egress_acl_vlan(esw, vport, vport->info.vlan,
|
|
|
d8f823 |
+ MLX5_FLOW_CONTEXT_ACTION_ALLOW);
|
|
|
d8f823 |
+ if (err)
|
|
|
d8f823 |
+ return err;
|
|
|
d8f823 |
|
|
|
d8f823 |
- spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
|
|
|
d8f823 |
- flow_act.action = MLX5_FLOW_CONTEXT_ACTION_ALLOW;
|
|
|
d8f823 |
- vport->egress.allowed_vlan =
|
|
|
d8f823 |
- mlx5_add_flow_rules(vport->egress.acl, spec,
|
|
|
d8f823 |
- &flow_act, NULL, 0);
|
|
|
d8f823 |
- if (IS_ERR(vport->egress.allowed_vlan)) {
|
|
|
d8f823 |
- err = PTR_ERR(vport->egress.allowed_vlan);
|
|
|
d8f823 |
- esw_warn(esw->dev,
|
|
|
d8f823 |
- "vport[%d] configure egress allowed vlan rule failed, err(%d)\n",
|
|
|
d8f823 |
- vport->vport, err);
|
|
|
d8f823 |
- vport->egress.allowed_vlan = NULL;
|
|
|
d8f823 |
+ /* Drop others rule (star rule) */
|
|
|
d8f823 |
+ spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
|
|
|
d8f823 |
+ if (!spec)
|
|
|
d8f823 |
goto out;
|
|
|
d8f823 |
- }
|
|
|
d8f823 |
|
|
|
d8f823 |
- /* Drop others rule (star rule) */
|
|
|
d8f823 |
- memset(spec, 0, sizeof(*spec));
|
|
|
d8f823 |
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
|
|
|
d8f823 |
|
|
|
d8f823 |
/* Attach egress drop flow counter */
|
|
|
d8f823 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
|
|
|
d8f823 |
index 436c633407d6..0cba334270d9 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
|
|
|
d8f823 |
@@ -423,6 +423,10 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
u16 vport, u16 vlan, u8 qos, u8 set_flags);
|
|
|
d8f823 |
|
|
|
d8f823 |
+int mlx5_esw_create_vport_egress_acl_vlan(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
+ struct mlx5_vport *vport,
|
|
|
d8f823 |
+ u16 vlan_id, u32 flow_action);
|
|
|
d8f823 |
+
|
|
|
d8f823 |
static inline bool mlx5_eswitch_vlan_actions_supported(struct mlx5_core_dev *dev,
|
|
|
d8f823 |
u8 vlan_depth)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
|
d8f823 |
index 9e64bdf17861..657aeea3f879 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
|
|
|
d8f823 |
@@ -1859,48 +1859,6 @@ void esw_vport_del_ingress_acl_modify_metadata(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
}
|
|
|
d8f823 |
}
|
|
|
d8f823 |
|
|
|
d8f823 |
-static int esw_vport_egress_prio_tag_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
- struct mlx5_vport *vport)
|
|
|
d8f823 |
-{
|
|
|
d8f823 |
- struct mlx5_flow_act flow_act = {0};
|
|
|
d8f823 |
- struct mlx5_flow_spec *spec;
|
|
|
d8f823 |
- int err = 0;
|
|
|
d8f823 |
-
|
|
|
d8f823 |
- /* For prio tag mode, there is only 1 FTEs:
|
|
|
d8f823 |
- * 1) prio tag packets - pop the prio tag VLAN, allow
|
|
|
d8f823 |
- * Unmatched traffic is allowed by default
|
|
|
d8f823 |
- */
|
|
|
d8f823 |
- esw_debug(esw->dev,
|
|
|
d8f823 |
- "vport[%d] configure prio tag egress rules\n", vport->vport);
|
|
|
d8f823 |
-
|
|
|
d8f823 |
- spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
|
|
|
d8f823 |
- if (!spec)
|
|
|
d8f823 |
- return -ENOMEM;
|
|
|
d8f823 |
-
|
|
|
d8f823 |
- /* prio tag vlan rule - pop it so VF receives untagged packets */
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.cvlan_tag);
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_value, outer_headers.cvlan_tag);
|
|
|
d8f823 |
- MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.first_vid);
|
|
|
d8f823 |
- MLX5_SET(fte_match_param, spec->match_value, outer_headers.first_vid, 0);
|
|
|
d8f823 |
-
|
|
|
d8f823 |
- spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
|
|
|
d8f823 |
- flow_act.action = MLX5_FLOW_CONTEXT_ACTION_VLAN_POP |
|
|
|
d8f823 |
- MLX5_FLOW_CONTEXT_ACTION_ALLOW;
|
|
|
d8f823 |
- vport->egress.allowed_vlan =
|
|
|
d8f823 |
- mlx5_add_flow_rules(vport->egress.acl, spec,
|
|
|
d8f823 |
- &flow_act, NULL, 0);
|
|
|
d8f823 |
- if (IS_ERR(vport->egress.allowed_vlan)) {
|
|
|
d8f823 |
- err = PTR_ERR(vport->egress.allowed_vlan);
|
|
|
d8f823 |
- esw_warn(esw->dev,
|
|
|
d8f823 |
- "vport[%d] configure egress pop prio tag vlan rule failed, err(%d)\n",
|
|
|
d8f823 |
- vport->vport, err);
|
|
|
d8f823 |
- vport->egress.allowed_vlan = NULL;
|
|
|
d8f823 |
- }
|
|
|
d8f823 |
-
|
|
|
d8f823 |
- kvfree(spec);
|
|
|
d8f823 |
- return err;
|
|
|
d8f823 |
-}
|
|
|
d8f823 |
-
|
|
|
d8f823 |
static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
struct mlx5_vport *vport)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
@@ -1956,9 +1914,17 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
if (err)
|
|
|
d8f823 |
return err;
|
|
|
d8f823 |
|
|
|
d8f823 |
- esw_debug(esw->dev, "vport(%d) configure egress rules\n", vport->vport);
|
|
|
d8f823 |
+ /* For prio tag mode, there is only 1 FTEs:
|
|
|
d8f823 |
+ * 1) prio tag packets - pop the prio tag VLAN, allow
|
|
|
d8f823 |
+ * Unmatched traffic is allowed by default
|
|
|
d8f823 |
+ */
|
|
|
d8f823 |
+ esw_debug(esw->dev,
|
|
|
d8f823 |
+ "vport[%d] configure prio tag egress rules\n", vport->vport);
|
|
|
d8f823 |
|
|
|
d8f823 |
- err = esw_vport_egress_prio_tag_config(esw, vport);
|
|
|
d8f823 |
+ /* prio tag vlan rule - pop it so VF receives untagged packets */
|
|
|
d8f823 |
+ err = mlx5_esw_create_vport_egress_acl_vlan(esw, vport, 0,
|
|
|
d8f823 |
+ MLX5_FLOW_CONTEXT_ACTION_VLAN_POP |
|
|
|
d8f823 |
+ MLX5_FLOW_CONTEXT_ACTION_ALLOW);
|
|
|
d8f823 |
if (err)
|
|
|
d8f823 |
esw_vport_disable_egress_acl(esw, vport);
|
|
|
d8f823 |
|
|
|
d8f823 |
--
|
|
|
d8f823 |
2.13.6
|
|
|
d8f823 |
|