Skip to content

Commit ffec970

Browse files
hao022Saeed Mahameed
authored andcommitted
net/mlx5e: Don't allow forwarding between uplink
We can install forwarding packets rule between uplink in switchdev mode, as show below. But the hardware does not do that as expected (mlnx_perf -i $PF1, we can't get the counter of the PF1). By the way, if we add the uplink PF0, PF1 to Open vSwitch and enable hw-offload, the rules can be offloaded but not work fine too. This patch add a check and if so return -EOPNOTSUPP. $ tc filter add dev $PF0 protocol all parent ffff: prio 1 handle 1 \ flower skip_sw action mirred egress redirect dev $PF1 $ tc -d -s filter show dev $PF0 ingress skip_sw in_hw in_hw_count 1 action order 1: mirred (Egress Redirect to device enp130s0f1) stolen ... Sent hardware 408954 bytes 4173 pkt ... Signed-off-by: Tonghao Zhang <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 37e1244 commit ffec970

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,11 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
14641464
.ndo_set_features = mlx5e_set_features,
14651465
};
14661466

1467+
bool mlx5e_eswitch_uplink_rep(struct net_device *netdev)
1468+
{
1469+
return netdev->netdev_ops == &mlx5e_netdev_ops_uplink_rep;
1470+
}
1471+
14671472
bool mlx5e_eswitch_rep(struct net_device *netdev)
14681473
{
14691474
if (netdev->netdev_ops == &mlx5e_netdev_ops_rep ||

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
200200
void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);
201201

202202
bool mlx5e_eswitch_rep(struct net_device *netdev);
203+
bool mlx5e_eswitch_uplink_rep(struct net_device *netdev);
203204

204205
#else /* CONFIG_MLX5_ESWITCH */
205206
static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; }

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,6 +3405,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
34053405
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
34063406
struct net_device *uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);
34073407
struct net_device *uplink_upper;
3408+
struct mlx5e_rep_priv *rep_priv;
34083409

34093410
if (is_duplicated_output_device(priv->netdev,
34103411
out_dev,
@@ -3440,6 +3441,22 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
34403441
return err;
34413442
}
34423443

3444+
/* Don't allow forwarding between uplink.
3445+
*
3446+
* Input vport was stored esw_attr->in_rep.
3447+
* In LAG case, *priv* is the private data of
3448+
* uplink which may be not the input vport.
3449+
*/
3450+
rep_priv = mlx5e_rep_to_rep_priv(attr->in_rep);
3451+
if (mlx5e_eswitch_uplink_rep(rep_priv->netdev) &&
3452+
mlx5e_eswitch_uplink_rep(out_dev)) {
3453+
NL_SET_ERR_MSG_MOD(extack,
3454+
"devices are both uplink, can't offload forwarding");
3455+
pr_err("devices %s %s are both uplink, can't offload forwarding\n",
3456+
priv->netdev->name, out_dev->name);
3457+
return -EOPNOTSUPP;
3458+
}
3459+
34433460
if (!mlx5e_is_valid_eswitch_fwd_dev(priv, out_dev)) {
34443461
NL_SET_ERR_MSG_MOD(extack,
34453462
"devices are not on same switch HW, can't offload forwarding");

0 commit comments

Comments
 (0)