netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dhananjay Phadke <dhananjay@netxen.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net
Subject: [PATCH 06/13] netxen: advertise wake-on-lan support
Date: Mon, 12 Jan 2009 11:23:04 -0800	[thread overview]
Message-ID: <1231788191-23794-7-git-send-email-dhananjay@netxen.com> (raw)
In-Reply-To: <1231788191-23794-1-git-send-email-dhananjay@netxen.com>

Advertise support for wake up on magic packet. Add control to
enable/disable WoL for each port.

Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
---
 drivers/net/netxen/netxen_nic_ethtool.c |   49 +++++++++++++++++++++++++++++++
 drivers/net/netxen/netxen_nic_hdr.h     |    2 +
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 48b20f6..b403f82 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -807,6 +807,53 @@ static int netxen_nic_set_tso(struct net_device *dev, u32 data)
 	return 0;
 }
 
+static void
+netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct netxen_adapter *adapter = netdev_priv(dev);
+	u32 wol_cfg = 0;
+
+	wol->supported = 0;
+	wol->wolopts = 0;
+
+	if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+		return;
+
+	wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+	if (wol_cfg & (1UL << adapter->portnum))
+		wol->supported |= WAKE_MAGIC;
+
+	wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+	if (wol_cfg & (1UL << adapter->portnum))
+		wol->wolopts |= WAKE_MAGIC;
+}
+
+static int
+netxen_nic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct netxen_adapter *adapter = netdev_priv(dev);
+	u32 wol_cfg = 0;
+
+	if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
+		return -EOPNOTSUPP;
+
+	if (wol->wolopts & ~WAKE_MAGIC)
+		return -EOPNOTSUPP;
+
+	wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV);
+	if (!(wol_cfg & (1 << adapter->portnum)))
+		return -EOPNOTSUPP;
+
+	wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG);
+	if (wol->wolopts & WAKE_MAGIC)
+		wol_cfg |= 1UL << adapter->portnum;
+	else
+		wol_cfg &= ~(1UL << adapter->portnum);
+	netxen_nic_reg_write(adapter, NETXEN_WOL_CONFIG, wol_cfg);
+
+	return 0;
+}
+
 /*
  * Set the coalescing parameters. Currently only normal is supported.
  * If rx_coalesce_usecs == 0 or rx_max_coalesced_frames == 0 then set the
@@ -913,6 +960,8 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
 	.set_sg = ethtool_op_set_sg,
 	.get_tso = netxen_nic_get_tso,
 	.set_tso = netxen_nic_set_tso,
+	.get_wol = netxen_nic_get_wol,
+	.set_wol = netxen_nic_set_wol,
 	.self_test = netxen_nic_diag_test,
 	.get_strings = netxen_nic_get_strings,
 	.get_ethtool_stats = netxen_nic_get_ethtool_stats,
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 269a1f7..b9f6893 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -857,6 +857,8 @@ enum {
 #define NETXEN_PORT_MODE_AUTO_NEG_XG	6
 #define NETXEN_PORT_MODE_ADDR		(NETXEN_CAM_RAM(0x24))
 #define NETXEN_WOL_PORT_MODE		(NETXEN_CAM_RAM(0x198))
+#define NETXEN_WOL_CONFIG_NV		(NETXEN_CAM_RAM(0x184))
+#define NETXEN_WOL_CONFIG		(NETXEN_CAM_RAM(0x188))
 
 #define NX_PEG_TUNE_MN_PRESENT		0x1
 #define NX_PEG_TUNE_CAPABILITY		(NETXEN_CAM_RAM(0x02c))
-- 
1.6.0.2


  parent reply	other threads:[~2009-01-12 19:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12 19:22 netxen: bugfixes and enhancements Dhananjay Phadke
2009-01-12 19:22 ` [PATCH 01/13] netxen: fix sparse in warnings Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 02/13] netxen: fix endianness in firmware commands Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 03/13] netxen: fix ipv6+vlan offload and tx cleanup Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 04/13] netxen: fix link speed reporting for some boards Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 05/13] netxen: download firmware from file Dhananjay Phadke
2009-01-12 19:23 ` Dhananjay Phadke [this message]
2009-01-12 19:23 ` [PATCH 07/13] netxen: cleanup mac list on driver unload Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 08/13] netxen: hold tx lock while sending firmware commands Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 09/13] netxen: handle dma mapping failures Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 10/13] netxen: misc code cleanup Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 11/13] netxen: remove unnecessary header includes Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 12/13] netxen: simplify dma mask setting Dhananjay Phadke
2009-01-12 19:23 ` [PATCH 13/13] netxen: raise version to 4.0.23 Dhananjay Phadke
2009-01-13  6:07 ` netxen: bugfixes and enhancements 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=1231788191-23794-7-git-send-email-dhananjay@netxen.com \
    --to=dhananjay@netxen.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).