Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 375f51e2 authored by Roi Dayan's avatar Roi Dayan Committed by David S. Miller
Browse files

net/mlx5: E-Switch, Don't allow changing inline mode when flows are configured



Changing the eswitch inline mode can potentially cause already configured
flows not to match the policy. E.g. set policy L4, add some L4 rules,
set policy to L2 --> bad! Hence we disallow it.

Keep track of how many offloaded rules are now set and refuse
inline mode changes if this isn't zero.

Fixes: bffaa916 ("net/mlx5: E-Switch, Add control for inline mode")
Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d85cdccb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -209,6 +209,7 @@ struct mlx5_esw_offload {
	struct mlx5_eswitch_rep *vport_reps;
	struct mlx5_eswitch_rep *vport_reps;
	DECLARE_HASHTABLE(encap_tbl, 8);
	DECLARE_HASHTABLE(encap_tbl, 8);
	u8 inline_mode;
	u8 inline_mode;
	u64 num_flows;
};
};


struct mlx5_eswitch {
struct mlx5_eswitch {
+8 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
				   spec, &flow_act, dest, i);
				   spec, &flow_act, dest, i);
	if (IS_ERR(rule))
	if (IS_ERR(rule))
		mlx5_fc_destroy(esw->dev, counter);
		mlx5_fc_destroy(esw->dev, counter);
	else
		esw->offloads.num_flows++;


	return rule;
	return rule;
}
}
@@ -108,6 +110,7 @@ mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
		counter = mlx5_flow_rule_counter(rule);
		counter = mlx5_flow_rule_counter(rule);
		mlx5_del_flow_rules(rule);
		mlx5_del_flow_rules(rule);
		mlx5_fc_destroy(esw->dev, counter);
		mlx5_fc_destroy(esw->dev, counter);
		esw->offloads.num_flows--;
	}
	}
}
}


@@ -922,6 +925,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode)
	    MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
	    MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;


	if (esw->offloads.num_flows > 0) {
		esw_warn(dev, "Can't set inline mode when flows are configured\n");
		return -EOPNOTSUPP;
	}

	err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
	err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
	if (err)
	if (err)
		goto out;
		goto out;