Commit 8e44c0ce authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum: Implement loopback ethtool feature

Allow user to enable loopback feature for individual ports using ethtool.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a0c25387
......@@ -1669,6 +1669,25 @@ static int mlxsw_sp_feature_hw_tc(struct net_device *dev, bool enable)
return 0;
}
static int mlxsw_sp_feature_loopback(struct net_device *dev, bool enable)
{
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
char pplr_pl[MLXSW_REG_PPLR_LEN];
int err;
if (netif_running(dev))
mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false);
mlxsw_reg_pplr_pack(pplr_pl, mlxsw_sp_port->local_port, enable);
err = mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pplr),
pplr_pl);
if (netif_running(dev))
mlxsw_sp_port_admin_status_set(mlxsw_sp_port, true);
return err;
}
typedef int (*mlxsw_sp_feature_handler)(struct net_device *dev, bool enable);
static int mlxsw_sp_handle_feature(struct net_device *dev,
......@@ -1700,8 +1719,20 @@ static int mlxsw_sp_handle_feature(struct net_device *dev,
static int mlxsw_sp_set_features(struct net_device *dev,
netdev_features_t features)
{
return mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC,
netdev_features_t oper_features = dev->features;
int err = 0;
err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC,
mlxsw_sp_feature_hw_tc);
err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_LOOPBACK,
mlxsw_sp_feature_loopback);
if (err) {
dev->features = oper_features;
return -EINVAL;
}
return 0;
}
static struct devlink_port *
......@@ -3452,7 +3483,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
dev->features |= NETIF_F_NETNS_LOCAL | NETIF_F_LLTX | NETIF_F_SG |
NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC;
dev->hw_features |= NETIF_F_HW_TC;
dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK;
dev->min_mtu = 0;
dev->max_mtu = ETH_MAX_MTU;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment