net: dsa: add {get, set}_wol callbacks to slave devices
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 19 Sep 2014 00:31:24 +0000 (17:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Sep 2014 18:41:23 +0000 (14:41 -0400)
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>
include/net/dsa.h
net/dsa/slave.c

index 846dce4abaa5db7f6d661d62d84029138a3f292d..d8054fb4a4dffaf45d3864b938d99ffb6c32b6bd 100644 (file)
@@ -211,6 +211,14 @@ struct dsa_switch_driver {
                                     int port, uint64_t *data);
        int     (*get_sset_count)(struct dsa_switch *ds);
 
+       /*
+        * ethtool Wake-on-LAN
+        */
+       void    (*get_wol)(struct dsa_switch *ds, int port,
+                          struct ethtool_wolinfo *w);
+       int     (*set_wol)(struct dsa_switch *ds, int port,
+                          struct ethtool_wolinfo *w);
+
        /*
         * Suspend and resume
         */
index 143811ef57aec14c847a44755274ca4bab8a6a21..43c1e4ade6892356fbc13ff5c6fefec4ea776f21 100644 (file)
@@ -301,6 +301,27 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
        return -EOPNOTSUPP;
 }
 
+static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
+{
+       struct dsa_slave_priv *p = netdev_priv(dev);
+       struct dsa_switch *ds = p->parent;
+
+       if (ds->drv->get_wol)
+               ds->drv->get_wol(ds, p->port, w);
+}
+
+static int dsa_slave_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
+{
+       struct dsa_slave_priv *p = netdev_priv(dev);
+       struct dsa_switch *ds = p->parent;
+       int ret = -EOPNOTSUPP;
+
+       if (ds->drv->set_wol)
+               ret = ds->drv->set_wol(ds, p->port, w);
+
+       return ret;
+}
+
 static const struct ethtool_ops dsa_slave_ethtool_ops = {
        .get_settings           = dsa_slave_get_settings,
        .set_settings           = dsa_slave_set_settings,
@@ -310,6 +331,8 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
        .get_strings            = dsa_slave_get_strings,
        .get_ethtool_stats      = dsa_slave_get_ethtool_stats,
        .get_sset_count         = dsa_slave_get_sset_count,
+       .set_wol                = dsa_slave_set_wol,
+       .get_wol                = dsa_slave_get_wol,
 };
 
 static const struct net_device_ops dsa_slave_netdev_ops = {