netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 3/4] net: dsa: add {get,set}_wol callbacks to slave devices
Date: Thu, 18 Sep 2014 17:31:24 -0700	[thread overview]
Message-ID: <1411086685-18684-4-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1411086685-18684-1-git-send-email-f.fainelli@gmail.com>

Allow switch drivers to implement per-port Wake-on-LAN getter and
setters.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/net/dsa.h |  8 ++++++++
 net/dsa/slave.c   | 23 +++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 0a34bf3d1ddd..1de4efff4e42 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -211,6 +211,14 @@ struct dsa_switch_driver {
 	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
 	 */
 	int	(*suspend)(struct dsa_switch *ds);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e11c9bdca6e6..db53c1bf998c 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)
 	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 = {
-- 
1.9.1

  parent reply	other threads:[~2014-09-19  0:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19  0:31 [PATCH net-next 0/4] dsa: Broadcom SF2 suspend/resume and WoL Florian Fainelli
2014-09-19  0:31 ` [PATCH net-next 1/4] net: dsa: allow switch drivers to implement suspend/resume hooks Florian Fainelli
2014-09-19  0:31 ` [PATCH net-next 2/4] net: dsa: bcm_sf2: add suspend/resume callbacks Florian Fainelli
2014-09-19  0:31 ` Florian Fainelli [this message]
2014-09-19  0:31 ` [PATCH net-next 4/4] net: dsa: bcm_sf2: add support for Wake-on-LAN Florian Fainelli
2014-09-22 18:41 ` [PATCH net-next 0/4] dsa: Broadcom SF2 suspend/resume and WoL David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411086685-18684-4-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).