Skip to content

Commit 8e44c0c

Browse files
jpirkodavem330
authored andcommitted
mlxsw: spectrum: Implement loopback ethtool feature
Allow user to enable loopback feature for individual ports using ethtool. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a0c2538 commit 8e44c0c

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,25 @@ static int mlxsw_sp_feature_hw_tc(struct net_device *dev, bool enable)
16691669
return 0;
16701670
}
16711671

1672+
static int mlxsw_sp_feature_loopback(struct net_device *dev, bool enable)
1673+
{
1674+
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
1675+
char pplr_pl[MLXSW_REG_PPLR_LEN];
1676+
int err;
1677+
1678+
if (netif_running(dev))
1679+
mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false);
1680+
1681+
mlxsw_reg_pplr_pack(pplr_pl, mlxsw_sp_port->local_port, enable);
1682+
err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr),
1683+
pplr_pl);
1684+
1685+
if (netif_running(dev))
1686+
mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true);
1687+
1688+
return err;
1689+
}
1690+
16721691
typedef int (*mlxsw_sp_feature_handler)(struct net_device *dev, bool enable);
16731692

16741693
static int mlxsw_sp_handle_feature(struct net_device *dev,
@@ -1700,8 +1719,20 @@ static int mlxsw_sp_handle_feature(struct net_device *dev,
17001719
static int mlxsw_sp_set_features(struct net_device *dev,
17011720
netdev_features_t features)
17021721
{
1703-
return mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC,
1722+
netdev_features_t oper_features = dev->features;
1723+
int err = 0;
1724+
1725+
err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC,
17041726
mlxsw_sp_feature_hw_tc);
1727+
err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_LOOPBACK,
1728+
mlxsw_sp_feature_loopback);
1729+
1730+
if (err) {
1731+
dev->features = oper_features;
1732+
return -EINVAL;
1733+
}
1734+
1735+
return 0;
17051736
}
17061737

17071738
static struct devlink_port *
@@ -3452,7 +3483,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
34523483

34533484
dev->features |= NETIF_F_NETNS_LOCAL | NETIF_F_LLTX | NETIF_F_SG |
34543485
NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
3455-
dev->hw_features |= NETIF_F_HW_TC;
3486+
dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK;
34563487

34573488
dev->min_mtu = 0;
34583489
dev->max_mtu = ETH_MAX_MTU;

0 commit comments

Comments
 (0)