Skip to content

Commit 8f8ae89

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Ignore attempts to offload multiple times a TC flow
For VF->VF and uplink->VF rules, the TC core (cls_api) attempts to offload the same flow multiple times into the driver, b/c we registered to the egdev callback. Use the flow cookie to ignore attempts to add such flows, we can't reject them (return error), b/c this will fail the offload attempt, so we ignore that. We indentify wrong stat/del calls using the flow ingress/egress flags, here we do return error to the core. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Paul Blakey <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 655dc3d commit 8f8ae89

File tree

1 file changed

+19
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+19
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,6 +2666,12 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
26662666

26672667
get_flags(flags, &flow_flags);
26682668

2669+
flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params);
2670+
if (flow) {
2671+
netdev_warn_once(priv->netdev, "flow cookie %lx already exists, ignoring\n", f->cookie);
2672+
return 0;
2673+
}
2674+
26692675
if (esw && esw->mode == SRIOV_OFFLOADS) {
26702676
flow_flags |= MLX5E_TC_FLOW_ESWITCH;
26712677
attr_size = sizeof(struct mlx5_esw_flow_attr);
@@ -2728,14 +2734,25 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
27282734
return err;
27292735
}
27302736

2737+
#define DIRECTION_MASK (MLX5E_TC_INGRESS | MLX5E_TC_EGRESS)
2738+
#define FLOW_DIRECTION_MASK (MLX5E_TC_FLOW_INGRESS | MLX5E_TC_FLOW_EGRESS)
2739+
2740+
static bool same_flow_direction(struct mlx5e_tc_flow *flow, int flags)
2741+
{
2742+
if ((flow->flags & FLOW_DIRECTION_MASK) == (flags & DIRECTION_MASK))
2743+
return true;
2744+
2745+
return false;
2746+
}
2747+
27312748
int mlx5e_delete_flower(struct mlx5e_priv *priv,
27322749
struct tc_cls_flower_offload *f, int flags)
27332750
{
27342751
struct rhashtable *tc_ht = get_tc_ht(priv);
27352752
struct mlx5e_tc_flow *flow;
27362753

27372754
flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params);
2738-
if (!flow)
2755+
if (!flow || !same_flow_direction(flow, flags))
27392756
return -EINVAL;
27402757

27412758
rhashtable_remove_fast(tc_ht, &flow->node, tc_ht_params);
@@ -2758,7 +2775,7 @@ int mlx5e_stats_flower(struct mlx5e_priv *priv,
27582775
u64 lastuse;
27592776

27602777
flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params);
2761-
if (!flow)
2778+
if (!flow || !same_flow_direction(flow, flags))
27622779
return -EINVAL;
27632780

27642781
if (!(flow->flags & MLX5E_TC_FLOW_OFFLOADED))

0 commit comments

Comments
 (0)