diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2014-09-18 20:31:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-22 14:41:23 -0400 |
commit | 19e57c4e6dc6b82a3204b801f4c5f27c7d007559 (patch) | |
tree | 24b25dd20cb1cbdb329926a774a2395b5a2bb3b1 | |
parent | 8cfa94984c9cfdd5f5af2af4f161176cb7256d44 (diff) |
net: dsa: add {get, set}_wol callbacks to slave devices
Allow switch drivers to implement per-port Wake-on-LAN getter and
setters.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/dsa.h | 8 | ||||
-rw-r--r-- | net/dsa/slave.c | 23 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 846dce4abaa5..d8054fb4a4df 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -212,6 +212,14 @@ struct dsa_switch_driver { | |||
212 | int (*get_sset_count)(struct dsa_switch *ds); | 212 | int (*get_sset_count)(struct dsa_switch *ds); |
213 | 213 | ||
214 | /* | 214 | /* |
215 | * ethtool Wake-on-LAN | ||
216 | */ | ||
217 | void (*get_wol)(struct dsa_switch *ds, int port, | ||
218 | struct ethtool_wolinfo *w); | ||
219 | int (*set_wol)(struct dsa_switch *ds, int port, | ||
220 | struct ethtool_wolinfo *w); | ||
221 | |||
222 | /* | ||
215 | * Suspend and resume | 223 | * Suspend and resume |
216 | */ | 224 | */ |
217 | int (*suspend)(struct dsa_switch *ds); | 225 | int (*suspend)(struct dsa_switch *ds); |
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 143811ef57ae..43c1e4ade689 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -301,6 +301,27 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset) | |||
301 | return -EOPNOTSUPP; | 301 | return -EOPNOTSUPP; |
302 | } | 302 | } |
303 | 303 | ||
304 | static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) | ||
305 | { | ||
306 | struct dsa_slave_priv *p = netdev_priv(dev); | ||
307 | struct dsa_switch *ds = p->parent; | ||
308 | |||
309 | if (ds->drv->get_wol) | ||
310 | ds->drv->get_wol(ds, p->port, w); | ||
311 | } | ||
312 | |||
313 | static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) | ||
314 | { | ||
315 | struct dsa_slave_priv *p = netdev_priv(dev); | ||
316 | struct dsa_switch *ds = p->parent; | ||
317 | int ret = -EOPNOTSUPP; | ||
318 | |||
319 | if (ds->drv->set_wol) | ||
320 | ret = ds->drv->set_wol(ds, p->port, w); | ||
321 | |||
322 | return ret; | ||
323 | } | ||
324 | |||
304 | static const struct ethtool_ops dsa_slave_ethtool_ops = { | 325 | static const struct ethtool_ops dsa_slave_ethtool_ops = { |
305 | .get_settings = dsa_slave_get_settings, | 326 | .get_settings = dsa_slave_get_settings, |
306 | .set_settings = dsa_slave_set_settings, | 327 | .set_settings = dsa_slave_set_settings, |
@@ -310,6 +331,8 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { | |||
310 | .get_strings = dsa_slave_get_strings, | 331 | .get_strings = dsa_slave_get_strings, |
311 | .get_ethtool_stats = dsa_slave_get_ethtool_stats, | 332 | .get_ethtool_stats = dsa_slave_get_ethtool_stats, |
312 | .get_sset_count = dsa_slave_get_sset_count, | 333 | .get_sset_count = dsa_slave_get_sset_count, |
334 | .set_wol = dsa_slave_set_wol, | ||
335 | .get_wol = dsa_slave_get_wol, | ||
313 | }; | 336 | }; |
314 | 337 | ||
315 | static const struct net_device_ops dsa_slave_netdev_ops = { | 338 | static const struct net_device_ops dsa_slave_netdev_ops = { |