Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlxsw: spectrum: Implement loopback ethtool feature

Allow user to enable loopback feature for individual ports using ethtool.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jiri Pirko and committed by
David S. Miller
8e44c0ce a0c25387

+33 -2
+33 -2
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 1669 1669 return 0; 1670 1670 } 1671 1671 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 + 1672 1691 typedef int (*mlxsw_sp_feature_handler)(struct net_device *dev, bool enable); 1673 1692 1674 1693 static int mlxsw_sp_handle_feature(struct net_device *dev, ··· 1719 1700 static int mlxsw_sp_set_features(struct net_device *dev, 1720 1701 netdev_features_t features) 1721 1702 { 1722 - return mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC, 1703 + netdev_features_t oper_features = dev->features; 1704 + int err = 0; 1705 + 1706 + err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_HW_TC, 1723 1707 mlxsw_sp_feature_hw_tc); 1708 + err |= mlxsw_sp_handle_feature(dev, features, NETIF_F_LOOPBACK, 1709 + mlxsw_sp_feature_loopback); 1710 + 1711 + if (err) { 1712 + dev->features = oper_features; 1713 + return -EINVAL; 1714 + } 1715 + 1716 + return 0; 1724 1717 } 1725 1718 1726 1719 static struct devlink_port * ··· 3483 3452 3484 3453 dev->features |= NETIF_F_NETNS_LOCAL | NETIF_F_LLTX | NETIF_F_SG | 3485 3454 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_TC; 3486 - dev->hw_features |= NETIF_F_HW_TC; 3455 + dev->hw_features |= NETIF_F_HW_TC | NETIF_F_LOOPBACK; 3487 3456 3488 3457 dev->min_mtu = 0; 3489 3458 dev->max_mtu = ETH_MAX_MTU;