mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
Merge branch 'net-dsa-cleanup-eee-part-1'
Russell King says: ==================== net: dsa: cleanup EEE (part 1) First part of DSA EEE cleanups. Patch 1 removes a useless test that is always false. dp->pl will always be set for user ports, so !dp->pl in the EEE methods will always be false. Patch 2 adds support for a new DSA support_eee() method, which tells DSA whether the DSA driver supports EEE, and thus whether the ethtool set_eee() and get_eee() methods should return -EOPNOTSUPP. Patch 3 adds a trivial implementation for this new method which indicates that EEE is supported. Patches 4..8 adds implementations for .supports_eee() to all drivers that support EEE in some form. Patch 9 switches the core DSA code to require a .supports_eee() implementation if DSA is supported. Any DSA driver that doesn't implement this method after this patch will not support the ethtool EEE methods. Part 2 will remove the (now) useless .get_mac_eee() DSA operation. ==================== Link: https://patch.msgid.link/Z1hNkEb13FMuDQiY@shell.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
96b6fcc0ee
|
|
@ -2224,13 +2224,16 @@ int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy)
|
|||
}
|
||||
EXPORT_SYMBOL(b53_eee_init);
|
||||
|
||||
int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
|
||||
bool b53_support_eee(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct b53_device *dev = ds->priv;
|
||||
|
||||
if (is5325(dev) || is5365(dev))
|
||||
return -EOPNOTSUPP;
|
||||
return !is5325(dev) && !is5365(dev);
|
||||
}
|
||||
EXPORT_SYMBOL(b53_support_eee);
|
||||
|
||||
int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(b53_get_mac_eee);
|
||||
|
|
@ -2240,9 +2243,6 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
|
|||
struct b53_device *dev = ds->priv;
|
||||
struct ethtool_keee *p = &dev->ports[port].eee;
|
||||
|
||||
if (is5325(dev) || is5365(dev))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
p->eee_enabled = e->eee_enabled;
|
||||
b53_eee_enable_set(ds, port, e->eee_enabled);
|
||||
|
||||
|
|
@ -2298,6 +2298,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
|
|||
.phylink_get_caps = b53_phylink_get_caps,
|
||||
.port_enable = b53_enable_port,
|
||||
.port_disable = b53_disable_port,
|
||||
.support_eee = b53_support_eee,
|
||||
.get_mac_eee = b53_get_mac_eee,
|
||||
.set_mac_eee = b53_set_mac_eee,
|
||||
.port_bridge_join = b53_br_join,
|
||||
|
|
|
|||
|
|
@ -384,6 +384,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
|
|||
void b53_disable_port(struct dsa_switch *ds, int port);
|
||||
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
|
||||
int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
|
||||
bool b53_support_eee(struct dsa_switch *ds, int port);
|
||||
int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
|
||||
int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
|
||||
|
||||
|
|
|
|||
|
|
@ -1232,6 +1232,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
|
|||
.set_wol = bcm_sf2_sw_set_wol,
|
||||
.port_enable = bcm_sf2_port_setup,
|
||||
.port_disable = bcm_sf2_port_disable,
|
||||
.support_eee = b53_support_eee,
|
||||
.get_mac_eee = b53_get_mac_eee,
|
||||
.set_mac_eee = b53_set_mac_eee,
|
||||
.port_bridge_join = b53_br_join,
|
||||
|
|
|
|||
|
|
@ -3454,12 +3454,12 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
|
|||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int ksz_validate_eee(struct dsa_switch *ds, int port)
|
||||
static bool ksz_support_eee(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
|
||||
if (!dev->info->internal_phy[port])
|
||||
return -EOPNOTSUPP;
|
||||
return false;
|
||||
|
||||
switch (dev->chip_id) {
|
||||
case KSZ8563_CHIP_ID:
|
||||
|
|
@ -3471,21 +3471,15 @@ static int ksz_validate_eee(struct dsa_switch *ds, int port)
|
|||
case KSZ9896_CHIP_ID:
|
||||
case KSZ9897_CHIP_ID:
|
||||
case LAN9646_CHIP_ID:
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
|
||||
struct ethtool_keee *e)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ksz_validate_eee(ds, port);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* There is no documented control of Tx LPI configuration. */
|
||||
e->tx_lpi_enabled = true;
|
||||
|
||||
|
|
@ -3501,11 +3495,6 @@ static int ksz_set_mac_eee(struct dsa_switch *ds, int port,
|
|||
struct ethtool_keee *e)
|
||||
{
|
||||
struct ksz_device *dev = ds->priv;
|
||||
int ret;
|
||||
|
||||
ret = ksz_validate_eee(ds, port);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!e->tx_lpi_enabled) {
|
||||
dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n");
|
||||
|
|
@ -4651,6 +4640,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
|
|||
.cls_flower_add = ksz_cls_flower_add,
|
||||
.cls_flower_del = ksz_cls_flower_del,
|
||||
.port_setup_tc = ksz_setup_tc,
|
||||
.support_eee = ksz_support_eee,
|
||||
.get_mac_eee = ksz_get_mac_eee,
|
||||
.set_mac_eee = ksz_set_mac_eee,
|
||||
.port_get_default_prio = ksz_port_get_default_prio,
|
||||
|
|
|
|||
|
|
@ -3238,6 +3238,7 @@ const struct dsa_switch_ops mt7530_switch_ops = {
|
|||
.port_mirror_add = mt753x_port_mirror_add,
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
.phylink_get_caps = mt753x_phylink_get_caps,
|
||||
.support_eee = dsa_supports_eee,
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
.set_mac_eee = mt753x_set_mac_eee,
|
||||
.conduit_state_change = mt753x_conduit_state_change,
|
||||
|
|
|
|||
|
|
@ -7099,6 +7099,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
|
|||
.get_sset_count = mv88e6xxx_get_sset_count,
|
||||
.port_max_mtu = mv88e6xxx_get_max_mtu,
|
||||
.port_change_mtu = mv88e6xxx_change_mtu,
|
||||
.support_eee = dsa_supports_eee,
|
||||
.get_mac_eee = mv88e6xxx_get_mac_eee,
|
||||
.set_mac_eee = mv88e6xxx_set_mac_eee,
|
||||
.get_eeprom_len = mv88e6xxx_get_eeprom_len,
|
||||
|
|
|
|||
|
|
@ -2016,6 +2016,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = {
|
|||
.get_ethtool_stats = qca8k_get_ethtool_stats,
|
||||
.get_sset_count = qca8k_get_sset_count,
|
||||
.set_ageing_time = qca8k_set_ageing_time,
|
||||
.support_eee = dsa_supports_eee,
|
||||
.get_mac_eee = qca8k_get_mac_eee,
|
||||
.set_mac_eee = qca8k_set_mac_eee,
|
||||
.port_enable = qca8k_port_enable,
|
||||
|
|
|
|||
|
|
@ -988,6 +988,7 @@ struct dsa_switch_ops {
|
|||
/*
|
||||
* Port's MAC EEE settings
|
||||
*/
|
||||
bool (*support_eee)(struct dsa_switch *ds, int port);
|
||||
int (*set_mac_eee)(struct dsa_switch *ds, int port,
|
||||
struct ethtool_keee *e);
|
||||
int (*get_mac_eee)(struct dsa_switch *ds, int port,
|
||||
|
|
@ -1383,5 +1384,6 @@ static inline bool dsa_user_dev_check(const struct net_device *dev)
|
|||
|
||||
netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev);
|
||||
void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
|
||||
bool dsa_supports_eee(struct dsa_switch *ds, int port);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1575,6 +1575,22 @@ void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
|
|||
cpu_dp->tag_ops = tag_ops;
|
||||
}
|
||||
|
||||
/* dsa_supports_eee - indicate that EEE is supported
|
||||
* @ds: pointer to &struct dsa_switch
|
||||
* @port: port index
|
||||
*
|
||||
* A default implementation for the .support_eee() DSA operations member,
|
||||
* which drivers can use to indicate that they support EEE on all of their
|
||||
* user ports.
|
||||
*
|
||||
* Returns: true
|
||||
*/
|
||||
bool dsa_supports_eee(struct dsa_switch *ds, int port)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dsa_supports_eee);
|
||||
|
||||
static void dsa_port_phylink_mac_config(struct phylink_config *config,
|
||||
unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
|
|
|
|||
|
|
@ -1229,8 +1229,12 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_keee *e)
|
|||
struct dsa_switch *ds = dp->ds;
|
||||
int ret;
|
||||
|
||||
/* Check whether the switch supports EEE */
|
||||
if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Port's PHY and MAC both need to be EEE capable */
|
||||
if (!dev->phydev || !dp->pl)
|
||||
if (!dev->phydev)
|
||||
return -ENODEV;
|
||||
|
||||
if (!ds->ops->set_mac_eee)
|
||||
|
|
@ -1249,8 +1253,12 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e)
|
|||
struct dsa_switch *ds = dp->ds;
|
||||
int ret;
|
||||
|
||||
/* Check whether the switch supports EEE */
|
||||
if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Port's PHY and MAC both need to be EEE capable */
|
||||
if (!dev->phydev || !dp->pl)
|
||||
if (!dev->phydev)
|
||||
return -ENODEV;
|
||||
|
||||
if (!ds->ops->get_mac_eee)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user