Skip to content

Commit d85cdcc

Browse files
ogerlitzdavem330
authored andcommitted
net/mlx5e: Change the TC offload rule add/del code path to be per NIC or E-Switch
Refactor the code to deal with add/del TC rules to have handler per NIC/E-switch offloading use case, and push the latter into the e-switch code. This provides better separation and is to be used in down-stream patch for applying a fix. Fixes: bffaa91 ("net/mlx5: E-Switch, Add control for inline mode") Signed-off-by: Or Gerlitz <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1f30a86 commit d85cdcc

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed

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

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
133133
return rule;
134134
}
135135

136+
static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
137+
struct mlx5e_tc_flow *flow)
138+
{
139+
struct mlx5_fc *counter = NULL;
140+
141+
if (!IS_ERR(flow->rule)) {
142+
counter = mlx5_flow_rule_counter(flow->rule);
143+
mlx5_del_flow_rules(flow->rule);
144+
mlx5_fc_destroy(priv->mdev, counter);
145+
}
146+
147+
if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
148+
mlx5_destroy_flow_table(priv->fs.tc.t);
149+
priv->fs.tc.t = NULL;
150+
}
151+
}
152+
136153
static struct mlx5_flow_handle *
137154
mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
138155
struct mlx5_flow_spec *spec,
@@ -149,7 +166,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
149166
}
150167

151168
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
152-
struct mlx5e_tc_flow *flow) {
169+
struct mlx5e_tc_flow *flow);
170+
171+
static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
172+
struct mlx5e_tc_flow *flow)
173+
{
174+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
175+
176+
mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
177+
178+
mlx5_eswitch_del_vlan_action(esw, flow->attr);
179+
180+
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
181+
mlx5e_detach_encap(priv, flow);
182+
}
183+
184+
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
185+
struct mlx5e_tc_flow *flow)
186+
{
153187
struct list_head *next = flow->encap.next;
154188

155189
list_del(&flow->encap);
@@ -173,25 +207,10 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
173207
static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
174208
struct mlx5e_tc_flow *flow)
175209
{
176-
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
177-
struct mlx5_fc *counter = NULL;
178-
179-
if (!IS_ERR(flow->rule)) {
180-
counter = mlx5_flow_rule_counter(flow->rule);
181-
mlx5_del_flow_rules(flow->rule);
182-
mlx5_fc_destroy(priv->mdev, counter);
183-
}
184-
185-
if (flow->flags & MLX5E_TC_FLOW_ESWITCH) {
186-
mlx5_eswitch_del_vlan_action(esw, flow->attr);
187-
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
188-
mlx5e_detach_encap(priv, flow);
189-
}
190-
191-
if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
192-
mlx5_destroy_flow_table(priv->fs.tc.t);
193-
priv->fs.tc.t = NULL;
194-
}
210+
if (flow->flags & MLX5E_TC_FLOW_ESWITCH)
211+
mlx5e_tc_del_fdb_flow(priv, flow);
212+
else
213+
mlx5e_tc_del_nic_flow(priv, flow);
195214
}
196215

197216
static void parse_vxlan_attr(struct mlx5_flow_spec *spec,

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ struct mlx5_flow_handle *
271271
mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
272272
struct mlx5_flow_spec *spec,
273273
struct mlx5_esw_flow_attr *attr);
274+
void
275+
mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
276+
struct mlx5_flow_handle *rule,
277+
struct mlx5_esw_flow_attr *attr);
278+
274279
struct mlx5_flow_handle *
275280
mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn);
276281

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
9797
return rule;
9898
}
9999

100+
void
101+
mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
102+
struct mlx5_flow_handle *rule,
103+
struct mlx5_esw_flow_attr *attr)
104+
{
105+
struct mlx5_fc *counter = NULL;
106+
107+
if (!IS_ERR(rule)) {
108+
counter = mlx5_flow_rule_counter(rule);
109+
mlx5_del_flow_rules(rule);
110+
mlx5_fc_destroy(esw->dev, counter);
111+
}
112+
}
113+
100114
static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
101115
{
102116
struct mlx5_eswitch_rep *rep;

0 commit comments

Comments
 (0)