diff mbox series

[RFC,net-next,1/3] net: ngbe: add Wake on Lan support

Message ID 6DD3D5EDF01AE3F5+20230605095527.57898-2-mengyuanlou@net-swift.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series wangxun nics add wol ncsi support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 5 maintainers not CCed: kuba@kernel.org davem@davemloft.net pabeni@redhat.com edumazet@google.com andrew@lunn.ch
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Mengyuan Lou June 5, 2023, 9:52 a.m. UTC
Implement ethtool_ops get_wol.
Implement Wake-on-LAN support.

Magic packets are checked by fw, for now just support
WAKE_MAGIC and do not supoort to set_wol.

Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
 drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 10 ++++++++++
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c    |  1 +
 2 files changed, 11 insertions(+)

Comments

Andrew Lunn June 5, 2023, 1 p.m. UTC | #1
On Mon, Jun 05, 2023 at 05:52:50PM +0800, Mengyuan Lou wrote:
> Implement ethtool_ops get_wol.
> Implement Wake-on-LAN support.
> 
> Magic packets are checked by fw, for now just support
> WAKE_MAGIC and do not supoort to set_wol.

So are you saying WOL cannot be disabled? A magic packet will always
wake the system?

Can you disable WoL by not calling device_set_wakeup_enable()? Can the
interrupt be masked to disable WoL?

Is this specific to ngbe? Does txgbe have different firmware and
different WoL support?

	  Andrew
Mengyuan Lou June 8, 2023, 7:27 a.m. UTC | #2
> 2023年6月5日 21:00,Andrew Lunn <andrew@lunn.ch> 写道:
> 
> On Mon, Jun 05, 2023 at 05:52:50PM +0800, Mengyuan Lou wrote:
>> Implement ethtool_ops get_wol.
>> Implement Wake-on-LAN support.
>> 
>> Magic packets are checked by fw, for now just support
>> WAKE_MAGIC and do not supoort to set_wol.
> 
> So are you saying WOL cannot be disabled? A magic packet will always
> wake the system?
> 
>  Can the
> interrupt be masked to disable WoL?
When Firmware find a magic packet, it will set the GPIO. 
Firmware do not care the interrupt of WOL.

> Can you disable WoL by not calling device_set_wakeup_enable()?
> 
It is work by calling device_set_wakeup_enable() to disable WOL.


> Is this specific to ngbe? Does txgbe have different firmware and
> different WoL support?
> 
I do not have NICs(txgbe)which is support to WOL.
I will add it after I will have tested it.


>  Andrew
> 
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
index 5b25834baf38..2bc54fdafb31 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
@@ -8,12 +8,22 @@ 
 #include "../libwx/wx_ethtool.h"
 #include "ngbe_ethtool.h"
 
+static void ngbe_get_wol(struct net_device *netdev,
+			 struct ethtool_wolinfo *wol)
+{
+	if (!netdev->wol_enabled)
+		return;
+	wol->supported = WAKE_MAGIC;
+	wol->wolopts = WAKE_MAGIC;
+}
+
 static const struct ethtool_ops ngbe_ethtool_ops = {
 	.get_drvinfo		= wx_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
 	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
 	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 	.nway_reset		= phy_ethtool_nway_reset,
+	.get_wol		= ngbe_get_wol,
 };
 
 void ngbe_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
index c99a5d3de72e..5d013ac3acd1 100644
--- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
+++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
@@ -628,6 +628,7 @@  static int ngbe_probe(struct pci_dev *pdev,
 	wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol);
 
 	device_set_wakeup_enable(&pdev->dev, wx->wol);
+	netdev->wol_enabled = wx->wol_enabled;
 
 	/* Save off EEPROM version number and Option Rom version which
 	 * together make a unique identify for the eeprom