Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1700446
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 01/11] net: dsa: make EEE ops optional |
| Date | 2017-08-01 00:30 +0200 |
| Message-ID | <u9rmi-3wp-39@gated-at.bofh.it> (permalink) |
| References | <u9rmh-3wp-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Even though EEE implies the port's PHY and MAC of both ends, a switch
may not need to do anything to configure the port's MAC.
This makes it impossible for the DSA layer to distinguish e.g. this case
from a disabled EEE when a driver returns 0 from the get EEE operation.
For this reason, make the EEE ops optional and call them only when
provided. Calling it first allows a switch driver to stop the whole
operation at runtime if a given switch does not support the EEE setting.
If both the MAC operation and PHY are not present, -ENODEV is returned.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/slave.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9507bd38cf04..518145ced434 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -646,38 +646,42 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
- int ret;
+ int err = -ENODEV;
- if (!ds->ops->set_eee)
- return -EOPNOTSUPP;
+ if (ds->ops->set_eee) {
+ err = ds->ops->set_eee(ds, p->dp->index, p->phy, e);
+ if (err)
+ return err;
+ }
- ret = ds->ops->set_eee(ds, p->dp->index, p->phy, e);
- if (ret)
- return ret;
+ if (p->phy) {
+ err = phy_ethtool_set_eee(p->phy, e);
+ if (err)
+ return err;
+ }
- if (p->phy)
- ret = phy_ethtool_set_eee(p->phy, e);
-
- return ret;
+ return err;
}
static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->dp->ds;
- int ret;
+ int err = -ENODEV;
- if (!ds->ops->get_eee)
- return -EOPNOTSUPP;
+ if (ds->ops->get_eee) {
+ err = ds->ops->get_eee(ds, p->dp->index, e);
+ if (err)
+ return err;
+ }
- ret = ds->ops->get_eee(ds, p->dp->index, e);
- if (ret)
- return ret;
+ if (p->phy) {
+ err = phy_ethtool_get_eee(p->phy, e);
+ if (err)
+ return err;
+ }
- if (p->phy)
- ret = phy_ethtool_get_eee(p->phy, e);
-
- return ret;
+ return err;
}
#ifdef CONFIG_NET_POLL_CONTROLLER
--
2.13.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 00/11] net: dsa: rework EEE support Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 03/11] net: dsa: qca8k: enable EEE once Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 02/11] net: dsa: qca8k: fix EEE init Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 11/11] net: dsa: rename switch EEE ops Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 09/11] net: dsa: remove PHY device argument from .set_eee Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 04/11] net: dsa: qca8k: do not cache unneeded EEE fields Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 01/11] net: dsa: make EEE ops optional Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
Re: [PATCH net-next 01/11] net: dsa: make EEE ops optional Andrew Lunn <andrew@lunn.ch> - 2017-08-01 16:10 +0200
[PATCH net-next 06/11] net: dsa: bcm_sf2: remove unneeded supported flags Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
[PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 00:30 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Andrew Lunn <andrew@lunn.ch> - 2017-08-01 16:30 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 17:40 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Andrew Lunn <andrew@lunn.ch> - 2017-08-01 18:10 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 18:40 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-01 22:20 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Florian Fainelli <f.fainelli@gmail.com> - 2017-08-01 18:40 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Andrew Lunn <andrew@lunn.ch> - 2017-08-01 19:30 +0200
Re: [PATCH net-next 10/11] net: dsa: mv88e6xxx: remove EEE support Florian Fainelli <f.fainelli@gmail.com> - 2017-08-01 21:00 +0200
Re: [PATCH net-next 00/11] net: dsa: rework EEE support Andrew Lunn <andrew@lunn.ch> - 2017-08-01 16:40 +0200
csiph-web