Skip to content

Commit 14624d7

Browse files
roidayanSaeed Mahameed
authored andcommitted
net/mlx5e: Don't use termination table when redundant
Current code used termination table for each vport destination while it's only required for hairpin, i.e. uplink to uplink, or when vlan push on rx action being used. Fix to skip using termination table for vport destinations that do not require it. Signed-off-by: Roi Dayan <[email protected]> Reviewed-by: Maor Dickman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2d04e1c commit 14624d7

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,18 @@ static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
210210
return (port_mask & port_value) == MLX5_VPORT_UPLINK;
211211
}
212212

213+
static bool
214+
mlx5_eswitch_is_push_vlan_no_cap(struct mlx5_eswitch *esw,
215+
struct mlx5_flow_act *flow_act)
216+
{
217+
if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH &&
218+
!(mlx5_fs_get_capabilities(esw->dev, MLX5_FLOW_NAMESPACE_FDB) &
219+
MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX))
220+
return true;
221+
222+
return false;
223+
}
224+
213225
bool
214226
mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
215227
struct mlx5_flow_attr *attr,
@@ -225,10 +237,7 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
225237
(!mlx5_eswitch_offload_is_uplink_port(esw, spec) && !esw_attr->int_port))
226238
return false;
227239

228-
/* push vlan on RX */
229-
if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH &&
230-
!(mlx5_fs_get_capabilities(esw->dev, MLX5_FLOW_NAMESPACE_FDB) &
231-
MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX))
240+
if (mlx5_eswitch_is_push_vlan_no_cap(esw, flow_act))
232241
return true;
233242

234243
/* hairpin */
@@ -252,19 +261,31 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
252261
struct mlx5_flow_act term_tbl_act = {};
253262
struct mlx5_flow_handle *rule = NULL;
254263
bool term_table_created = false;
264+
bool is_push_vlan_on_rx;
255265
int num_vport_dests = 0;
256266
int i, curr_dest;
257267

268+
is_push_vlan_on_rx = mlx5_eswitch_is_push_vlan_no_cap(esw, flow_act);
258269
mlx5_eswitch_termtbl_actions_move(flow_act, &term_tbl_act);
259270
term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
260271

261272
for (i = 0; i < num_dest; i++) {
262273
struct mlx5_termtbl_handle *tt;
274+
bool hairpin = false;
263275

264276
/* only vport destinations can be terminated */
265277
if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
266278
continue;
267279

280+
if (attr->dests[num_vport_dests].rep &&
281+
attr->dests[num_vport_dests].rep->vport == MLX5_VPORT_UPLINK)
282+
hairpin = true;
283+
284+
if (!is_push_vlan_on_rx && !hairpin) {
285+
num_vport_dests++;
286+
continue;
287+
}
288+
268289
if (attr->dests[num_vport_dests].flags & MLX5_ESW_DEST_ENCAP) {
269290
term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
270291
term_tbl_act.pkt_reformat = attr->dests[num_vport_dests].pkt_reformat;
@@ -312,6 +333,9 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
312333
for (curr_dest = 0; curr_dest < num_vport_dests; curr_dest++) {
313334
struct mlx5_termtbl_handle *tt = attr->dests[curr_dest].termtbl;
314335

336+
if (!tt)
337+
continue;
338+
315339
attr->dests[curr_dest].termtbl = NULL;
316340

317341
/* search for the destination associated with the

0 commit comments

Comments
 (0)