diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2023-08-16 14:02:11 +0100 |
---|---|---|
committer | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2024-04-16 16:51:03 +0100 |
commit | 6c0aad491228a975f59dc65daad55e272f663d70 (patch) | |
tree | f3989e02eaf48eaa47b2b8b2474ebd26672ae9fe /net | |
parent | c716326e24fce4592ad6265ceeb1a1cee392d136 (diff) |
net: dsa: add support for phylink managed EEE
Add support to allow DSA drivers to use phylink managed EEE, with only
needing support for controlling the LPI state.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'net')
-rw-r--r-- | net/dsa/port.c | 22 | ||||
-rw-r--r-- | net/dsa/user.c | 42 |
2 files changed, 48 insertions, 16 deletions
diff --git a/net/dsa/port.c b/net/dsa/port.c index c6febc3d96d9..f8499c50dd40 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1651,6 +1651,26 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config, speed, duplex, tx_pause, rx_pause); } +static void dsa_port_phylink_mac_disable_tx_lpi(struct phylink_config *config) +{ + struct dsa_port *dp = dsa_phylink_to_port(config); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->phylink_mac_disable_tx_lpi) + ds->ops->phylink_mac_disable_tx_lpi(ds, dp->index); + +} + +static void dsa_port_phylink_mac_enable_tx_lpi(struct phylink_config *config, + u32 timer) +{ + struct dsa_port *dp = dsa_phylink_to_port(config); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->phylink_mac_enable_tx_lpi) + ds->ops->phylink_mac_enable_tx_lpi(ds, dp->index, timer); +} + static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { .mac_select_pcs = dsa_port_phylink_mac_select_pcs, .mac_prepare = dsa_port_phylink_mac_prepare, @@ -1658,6 +1678,8 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { .mac_finish = dsa_port_phylink_mac_finish, .mac_link_down = dsa_port_phylink_mac_link_down, .mac_link_up = dsa_port_phylink_mac_link_up, + .mac_disable_tx_lpi = dsa_port_phylink_mac_disable_tx_lpi, + .mac_enable_tx_lpi = dsa_port_phylink_mac_enable_tx_lpi, }; int dsa_port_phylink_create(struct dsa_port *dp) diff --git a/net/dsa/user.c b/net/dsa/user.c index b556a4bf92c7..a0ee4d338d1f 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1228,16 +1228,21 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_eee *e) struct dsa_switch *ds = dp->ds; int ret; - /* Port's PHY and MAC both need to be EEE capable */ - if (!dev->phydev || !dp->pl) - return -ENODEV; + /* If the port is using phylink managed EEE, then get_mac_eee is + * unnecessary. + */ + if (!dp->pl_config.lpi_capabilities) { + /* Port's PHY and MAC both need to be EEE capable */ + if (!dev->phydev || !dp->pl) + return -ENODEV; - if (!ds->ops->set_mac_eee) - return -EOPNOTSUPP; + if (!ds->ops->set_mac_eee) + return -EOPNOTSUPP; - ret = ds->ops->set_mac_eee(ds, dp->index, e); - if (ret) - return ret; + ret = ds->ops->set_mac_eee(ds, dp->index, e); + if (ret) + return ret; + } return phylink_ethtool_set_eee(dp->pl, e); } @@ -1248,16 +1253,21 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_eee *e) struct dsa_switch *ds = dp->ds; int ret; - /* Port's PHY and MAC both need to be EEE capable */ - if (!dev->phydev || !dp->pl) - return -ENODEV; + /* If the port is using phylink managed EEE, then get_mac_eee is + * unnecessary. + */ + if (!dp->pl_config.lpi_capabilities) { + /* Port's PHY and MAC both need to be EEE capable */ + if (!dev->phydev || !dp->pl) + return -ENODEV; - if (!ds->ops->get_mac_eee) - return -EOPNOTSUPP; + if (!ds->ops->get_mac_eee) + return -EOPNOTSUPP; - ret = ds->ops->get_mac_eee(ds, dp->index, e); - if (ret) - return ret; + ret = ds->ops->get_mac_eee(ds, dp->index, e); + if (ret) + return ret; + } return phylink_ethtool_get_eee(dp->pl, e); } |