Skip to content

Commit 85ea2c5

Browse files
Jianbo LiuSaeed Mahameed
authored andcommitted
net/mlx5: E-switch, Change flow rule destination checking
The checking in the cited commit is not accurate. In the common case, VF destination is internal, and uplink destination is external. However, uplink destination with packet reformat is considered as internal because firmware uses LB+hairpin to support it. Update the checking so header rewrite rules with both internal and external destinations are not allowed. Fixes: e0e22d5 ("net/mlx5: E-switch, Add checking for flow rule destinations") Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Rahul Rameshbabu <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b7bbd69 commit 85ea2c5

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,21 +535,26 @@ esw_src_port_rewrite_supported(struct mlx5_eswitch *esw)
535535
}
536536

537537
static bool
538-
esw_dests_to_vf_pf_vports(struct mlx5_flow_destination *dests, int max_dest)
538+
esw_dests_to_int_external(struct mlx5_flow_destination *dests, int max_dest)
539539
{
540-
bool vf_dest = false, pf_dest = false;
540+
bool internal_dest = false, external_dest = false;
541541
int i;
542542

543543
for (i = 0; i < max_dest; i++) {
544-
if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
544+
if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT &&
545+
dests[i].type != MLX5_FLOW_DESTINATION_TYPE_UPLINK)
545546
continue;
546547

547-
if (dests[i].vport.num == MLX5_VPORT_UPLINK)
548-
pf_dest = true;
548+
/* Uplink dest is external, but considered as internal
549+
* if there is reformat because firmware uses LB+hairpin to support it.
550+
*/
551+
if (dests[i].vport.num == MLX5_VPORT_UPLINK &&
552+
!(dests[i].vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID))
553+
external_dest = true;
549554
else
550-
vf_dest = true;
555+
internal_dest = true;
551556

552-
if (vf_dest && pf_dest)
557+
if (internal_dest && external_dest)
553558
return true;
554559
}
555560

@@ -695,9 +700,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
695700

696701
/* Header rewrite with combined wire+loopback in FDB is not allowed */
697702
if ((flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) &&
698-
esw_dests_to_vf_pf_vports(dest, i)) {
703+
esw_dests_to_int_external(dest, i)) {
699704
esw_warn(esw->dev,
700-
"FDB: Header rewrite with forwarding to both PF and VF is not allowed\n");
705+
"FDB: Header rewrite with forwarding to both internal and external dests is not allowed\n");
701706
rule = ERR_PTR(-EINVAL);
702707
goto err_esw_get;
703708
}

0 commit comments

Comments
 (0)