Skip to content

Commit b20c2fb

Browse files
Chris Midavem330
authored andcommitted
net/mlx5: E-switch, Create ingress ACL when needed
Currently, ingress acl is used for three features. It is created only when vport metadata match and prio tag are enabled. But active-backup lag mode also uses it. It is independent of vport metadata match and prio tag. And vport metadata match can be disabled using the following devlink command: # devlink dev param set pci/0000:08:00.0 name esw_port_metadata \ value false cmode runtime If ingress acl is not created, will hit panic when creating drop rule for active-backup lag mode. If always create it, there will be about 5% performance degradation. Fix it by creating ingress acl when needed. If esw_port_metadata is true, ingress acl exists, then create drop rule using existing ingress acl. If esw_port_metadata is false, create ingress acl and then create drop rule. Fixes: 1749c4c ("net/mlx5: E-switch, add drop rule support to ingress ACL") Signed-off-by: Chris Mi <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5dbf647 commit b20c2fb

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_ofld.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include "helper.h"
77
#include "ofld.h"
88

9+
static int
10+
acl_ingress_ofld_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport);
11+
912
static bool
1013
esw_acl_ingress_prio_tag_enabled(struct mlx5_eswitch *esw,
1114
const struct mlx5_vport *vport)
@@ -123,18 +126,31 @@ static int esw_acl_ingress_src_port_drop_create(struct mlx5_eswitch *esw,
123126
{
124127
struct mlx5_flow_act flow_act = {};
125128
struct mlx5_flow_handle *flow_rule;
129+
bool created = false;
126130
int err = 0;
127131

132+
if (!vport->ingress.acl) {
133+
err = acl_ingress_ofld_setup(esw, vport);
134+
if (err)
135+
return err;
136+
created = true;
137+
}
138+
128139
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
129140
flow_act.fg = vport->ingress.offloads.drop_grp;
130141
flow_rule = mlx5_add_flow_rules(vport->ingress.acl, NULL, &flow_act, NULL, 0);
131142
if (IS_ERR(flow_rule)) {
132143
err = PTR_ERR(flow_rule);
133-
goto out;
144+
goto err_out;
134145
}
135146

136147
vport->ingress.offloads.drop_rule = flow_rule;
137-
out:
148+
149+
return 0;
150+
err_out:
151+
/* Only destroy ingress acl created in this function. */
152+
if (created)
153+
esw_acl_ingress_ofld_cleanup(esw, vport);
138154
return err;
139155
}
140156

@@ -299,16 +315,12 @@ static void esw_acl_ingress_ofld_groups_destroy(struct mlx5_vport *vport)
299315
}
300316
}
301317

302-
int esw_acl_ingress_ofld_setup(struct mlx5_eswitch *esw,
303-
struct mlx5_vport *vport)
318+
static int
319+
acl_ingress_ofld_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
304320
{
305321
int num_ftes = 0;
306322
int err;
307323

308-
if (!mlx5_eswitch_vport_match_metadata_enabled(esw) &&
309-
!esw_acl_ingress_prio_tag_enabled(esw, vport))
310-
return 0;
311-
312324
esw_acl_ingress_allow_rule_destroy(vport);
313325

314326
if (mlx5_eswitch_vport_match_metadata_enabled(esw))
@@ -347,6 +359,15 @@ int esw_acl_ingress_ofld_setup(struct mlx5_eswitch *esw,
347359
return err;
348360
}
349361

362+
int esw_acl_ingress_ofld_setup(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
363+
{
364+
if (!mlx5_eswitch_vport_match_metadata_enabled(esw) &&
365+
!esw_acl_ingress_prio_tag_enabled(esw, vport))
366+
return 0;
367+
368+
return acl_ingress_ofld_setup(esw, vport);
369+
}
370+
350371
void esw_acl_ingress_ofld_cleanup(struct mlx5_eswitch *esw,
351372
struct mlx5_vport *vport)
352373
{

0 commit comments

Comments
 (0)