Bug 218579 - Wake on Lan doesn't work for bge NIC driver
Summary: Wake on Lan doesn't work for bge NIC driver
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.2-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Cy Schubert
URL: https://www.nas4free.org/forums/viewt...
Keywords: needs-qa, patch, regression
: 171744 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-04-12 05:58 UTC by pozzugno
Modified: 2021-06-15 23:10 UTC (History)
9 users (show)

See Also:
koobs: mfc-stable11?
koobs: mfc-stable10?


Attachments
if_bge.c patched with the bge-WOL patch from https://bitbucket.org/w4w/bge-wol-freebsd-10.1-patch/overview (200.63 KB, text/x-csrc)
2017-10-03 01:55 UTC, thfrdue
no flags Details
WOL patch for bge. (4.97 KB, patch)
2018-03-02 17:59 UTC, Cy Schubert
no flags Details | Diff
WOL patch for stable/11 (5.80 KB, patch)
2018-10-02 01:02 UTC, Cy Schubert
no flags Details | Diff
Latest WOL patch for bge (5.88 KB, patch)
2020-03-13 20:14 UTC, Cy Schubert
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pozzugno 2017-04-12 05:58:56 UTC
I use Nas4Free on HP ProLiant MicroServer. Nas4Free is based on FreeBSD and I and some other people have a problem that is related to the bge NIC driver included in the last FreeBSD kernel.

We can't use Wake On Lan feature, even if it is enabled in BIOS. It is an issue with FreeBSD, because we can use WOL with other OS (such as Linux) on the same hw.

Someone noticed the WOL feature works if the NIC is connected to a Gigabit Ethernet, but not if the link is 100Mbps. Unfortunately I can't test Gigabit on my system.

Someone says older Nas4Free versions worked, for example that based on FreeBSD 9.2.

You can read much more details on a specific thread present on Nas4Free forum, here (https://www.nas4free.org/forums/viewtopic.php?f=58&t=4756&start=30).
Comment 1 thfrdue 2017-09-27 15:10:36 UTC
The same applies for FreeNAS which is also based on FreeBSD. With my HP ProLiant MicroServer N54L I have the same issue that WOL is not available - even with Gigabit ethernet connected.
Patches seem to exist (e.g., https://bitbucket.org/w4w/bge-wol-freebsd-10.1-patch).
Comment 2 thfrdue 2017-10-03 01:55:19 UTC
Created attachment 186870 [details]
if_bge.c patched with the bge-WOL patch from https://bitbucket.org/w4w/bge-wol-freebsd-10.1-patch/overview
Comment 3 Cy Schubert freebsd_committer 2018-03-02 17:59:36 UTC
Created attachment 191147 [details]
WOL patch for bge.

This patch was posted to PR 171744. The caveat is listed there, though the problem may simply be my laptop.

I'll consider closing either this or 171744 as a dup of the other.
Comment 4 Rodney W. Grimes freebsd_committer 2018-03-02 20:59:17 UTC
Please try not remove group assignment when "Taking" bugs.
Comment 5 Koen Martens 2018-03-19 19:31:30 UTC
Not sure what the fix is, and how 171744 is relevant (it's about the wake command, if I understand correctly).

Just wanted to chime in. I have a machine with a bge-driven card for which WOL worked perfectly with 10.3-RELEASE. I activated it with 'ifconfig bge0 wol_magic' and then used the wakeonlan utility on a linux (ubuntu 16.04) machine to wake up the freebsd machine.

Yesterday I upgraded to 11.1-RELEASE (something I have put off for ages because I was afraid something would break, but with the EOL coming up I decided to take the risk), and WOL just stopped working.

It isn't even advertised anymore as a capability in ifconfig:

# ifconfig -m bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
	capabilities=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
	ether 00:1e:c9:5b:75:11
	hwaddr 00:1e:c9:5b:75:11
	inet 10.1.3.8 netmask 0xffffff00 broadcast 10.1.3.255 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	supported media:
		media autoselect mediaopt flowcontrol
		media autoselect
		media 1000baseT mediaopt full-duplex,master
		media 1000baseT mediaopt full-duplex
		media 1000baseT mediaopt master
		media 1000baseT
		media 100baseTX mediaopt full-duplex
		media 100baseTX
		media 10baseT/UTP mediaopt full-duplex
		media 10baseT/UTP

Needless to say, 'ifconfig bge0 wol_magic' doesn't enable it anymore either.
Comment 6 Cy Schubert freebsd_committer 2018-03-19 19:43:23 UTC
I don't understand why it worked on 10.3. The WOL code was not in bge at the time. The patch is for 12-CURRENT. I'll rework it for 11-STABLE.
Comment 7 Cy Schubert freebsd_committer 2018-03-20 00:23:25 UTC
The patch attached to this PR also works with stable/11 and releng/11.1.
Comment 8 Koen Martens 2018-04-19 15:34:42 UTC
(In reply to Cy Schubert from comment #6)
Hi, thanks for the reply (and the reworked patch). I guess the patch won't go upstream because of the reasons mentioned (ie. potential to blow up boards that can't support enough power when the system is powered down)?

I'm also surprised it did work for me. I actually woke up the machine with wake-on-lan to ssh into it and upgrade it to 11.1-RELEASE.
Comment 9 Cy Schubert freebsd_committer 2018-04-20 00:56:27 UTC
(In reply to Koen Martens from comment #8)
That bug has been fixed in the latest patch I posted here. No worries about drawing too much current when powered off any more.

I've been using it and previous versions of this patch on my laptop (only machine I have with bge) for about a year.

I suppose I should submit the patch in phabricator for review prior to commit.
Comment 10 NK 2018-08-10 13:08:21 UTC
There still have issue with WOL patch for bge driver on FreeBSD 11.2.

It seems there is boot issues, see here:
https://www.xigmanas.com/forums/viewtopic.php?f=78&t=13807#p85480
Comment 11 Cy Schubert freebsd_committer 2018-10-01 04:04:53 UTC
(In reply to NK from comment #10)
Sketchy details. There's nothing to go on.

The WOL patch was developed for 12-CURRENT only. The only issue is a system will not halt -p after being woken by WOL, but will after a reboot.

I'll try to port it back to 11-STABLE if anyone is interested.
Comment 12 thfrdue 2018-10-01 18:51:04 UTC
(In reply to Cy Schubert from comment #11)
I would very much appreciate it. Thanks a lot for your efforts!
Comment 13 Cy Schubert freebsd_committer 2018-10-02 01:02:48 UTC
Created attachment 197700 [details]
WOL patch for stable/11

Same patch, for stable/11. I haven't tried to build or use this particular patch on stable/11. However a previous version was developed for current/11 at the time. This patch has the same problem as the -CURRENT patch, the system will reboot on halt -p the first time around. I'm not sure of the solution for this yet.
Comment 14 George B 2018-10-25 11:52:56 UTC
I had 11.1 patched with https://github.com/NamTaf/if_bge_wol and it worked 
can I apply the same patch on 11.2 p4 ?
I only need this for WOL.
Comment 15 Yiannis 2020-02-23 15:48:06 UTC
Any hope to make it work please ?
I have an old but full functional HP Microserver and I can't upgrade because of this issue.
A fix would really appreciated
Comment 16 Cy Schubert freebsd_committer 2020-03-13 20:14:51 UTC
Created attachment 212388 [details]
Latest WOL patch for bge

The patch generally works, I currently use it. However halt -p after a WOL will not power off the machine but reboot it. Only after the next reboot will it be able to power off. I don't know if this is isolated to my laptop only or if this is a general problem. Try the patch if it has the same behavior as on my laptop and report here or back to me your result.

Ping me if the patch posted here doesn't apply. I'll backport the one from 13-CURRENT again.
Comment 17 Cy Schubert freebsd_committer 2020-03-13 20:17:22 UTC
*** Bug 171744 has been marked as a duplicate of this bug. ***
Comment 18 tony 2021-06-07 09:35:07 UTC
Hy guys,

Can anyone explain me how to patch the driver? I cannot find the file if_bge.c anywhere...
is there a way to make it to one of the next version? this would be really appreciated!

Best

Tony
Comment 19 Chris Hutchinson 2021-06-07 15:39:45 UTC
(In reply to tony from comment #18)
> Can anyone explain me how to patch the driver?
copy your choice of one of the 2 attached diff files
to /usr/src.
# cd /usr/src
# patch < your-chosen-diff-file
Done.
see man diff && man patch for greater detail(s). :-)

> I cannot find the file if_bge.c anywhere...
# cd /usr/src
# find . -type f -name if_bge.c

> is there a way to make it to one of the next version?
> this would be really appreciated!

HTH

--Chris
Comment 20 Cy Schubert freebsd_committer 2021-06-07 16:02:21 UTC
(In reply to Chris Hutchinson from comment #19)
The latest patch is for 14-CURRENT. It works here except for a bug which I cannot track down. The bug is that after waking the machine the next time you do a halt -p the machine will reboot if the machine hasn't been rebooted using reboot in the mean time. It appears that some kind of status bit has been set in the NIC that when the machine powers itself off the first time after being woken it powers itself back on again. Only that once and only if there haven't been any reboots prior to that.

Otherwise this patch would have been committed long ago.

Please apply the patch and let me know if you experience this or if it is simply my laptop that has this problem. (My laptop doesn't experience this when booted from Windows 10 or Fedora, only with the patch I cobbled up for FreeBSD.)
Comment 21 HIROKI MORI 2021-06-15 22:50:02 UTC
I use acer note 3820. This machine have alc interface. alc support wol.
I can wol this machine on releng/13. But poweroff do reboot. 

I think wol poweroff problem is not driver issue. I doubt ACPI or other code.
Comment 22 Cy Schubert freebsd_committer 2021-06-15 23:10:58 UTC
Mine is an Acer 4752, same problem. Windows and Fedora don't have the problem. This suggests I've missed something in my patch.

But poweroff does work after that initial reboot following WOL. I suspect this is some bit in a NIC register that fails to be reset after WOL power up.