Skip to content

Commit 5067b60

Browse files
roidayandavem330
authored andcommitted
net/mlx5e: Remove flow encap entry in the correct place
Handling flow encap entry should be inside tc del flow and is only relevant for offloaded eswitch TC rules. Fixes: 11a457e9b6c1 ("net/mlx5e: Add basic TC tunnel set action for SRIOV offloads") Signed-off-by: Roi Dayan <roid@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 961e897 commit 5067b60

File tree

1 file changed

+22
-21
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+22
-21
lines changed

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
142142
return mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
143143
}
144144

145+
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
146+
struct mlx5e_tc_flow *flow) {
147+
struct list_head *next = flow->encap.next;
148+
149+
list_del(&flow->encap);
150+
if (list_empty(next)) {
151+
struct mlx5_encap_entry *e;
152+
153+
e = list_entry(next, struct mlx5_encap_entry, flows);
154+
if (e->n) {
155+
mlx5_encap_dealloc(priv->mdev, e->encap_id);
156+
neigh_release(e->n);
157+
}
158+
hlist_del_rcu(&e->encap_hlist);
159+
kfree(e);
160+
}
161+
}
162+
145163
static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
146164
struct mlx5e_tc_flow *flow)
147165
{
@@ -152,8 +170,11 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
152170

153171
mlx5_del_flow_rules(flow->rule);
154172

155-
if (esw && esw->mode == SRIOV_OFFLOADS)
173+
if (esw && esw->mode == SRIOV_OFFLOADS) {
156174
mlx5_eswitch_del_vlan_action(esw, flow->attr);
175+
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
176+
mlx5e_detach_encap(priv, flow);
177+
}
157178

158179
mlx5_fc_destroy(priv->mdev, counter);
159180

@@ -973,24 +994,6 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol,
973994
return err;
974995
}
975996

976-
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
977-
struct mlx5e_tc_flow *flow) {
978-
struct list_head *next = flow->encap.next;
979-
980-
list_del(&flow->encap);
981-
if (list_empty(next)) {
982-
struct mlx5_encap_entry *e;
983-
984-
e = list_entry(next, struct mlx5_encap_entry, flows);
985-
if (e->n) {
986-
mlx5_encap_dealloc(priv->mdev, e->encap_id);
987-
neigh_release(e->n);
988-
}
989-
hlist_del_rcu(&e->encap_hlist);
990-
kfree(e);
991-
}
992-
}
993-
994997
int mlx5e_delete_flower(struct mlx5e_priv *priv,
995998
struct tc_cls_flower_offload *f)
996999
{
@@ -1006,8 +1009,6 @@ int mlx5e_delete_flower(struct mlx5e_priv *priv,
10061009

10071010
mlx5e_tc_del_flow(priv, flow);
10081011

1009-
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
1010-
mlx5e_detach_encap(priv, flow);
10111012

10121013
kfree(flow);
10131014

0 commit comments

Comments
 (0)