WoL support for AN983B

I have a small server at home, which perfectly supports S3 (Suspend to RAM) state, but I did not get the server to wake up again under Linux 2.6 using a Wake-on-LAN (WoL) magic packet although I configured the BIOS accordingly.

The on-board Ethernet of the server is based on an AN983B chip, which supports PCI power management functions and several WoL wake-up events. This is what lspci shows:

02:01.0 Ethernet controller: ADMtek NC100 Network Everywhere Fast Ethernet 10/100 (rev 11)

The AN983B is supported by the tulip ethernet driver. This is what the tulip driver shows when loading:

Apr 20 20:36:23 gandalf eth0: ADMtek Comet rev 17 at MMIO 0xd0100000, 00:30:05:65:34:fe, IRQ 17.

However, the tulip driver does not support the WoL functions of the AN983B. The following patch adds support for link state change and magic packet WoL events to the tulip driver for this particular Ethernet chip.

The patch has only received minimal testing and is basically in „works for me“ state (i.e. it works for my uses cases on my hardware). Since my setup runs Ubuntu 8.04.3 LTS, the patch is for kernel 2.6.24.

When configuring the patched Kernel, you need to enable power management (CONFIG_PM) and the tulip driver, of course.

The patchs enable WoL only when suspending the system and not when shutting down the interface, which causes some problems with existing standby/resume scripts (see below for how to solve that on Ubuntu 8.04).

I currently have no time to maintain the patch nor to support it. I hope that this patch may still be useful for someone.

Update (June 2012): I just realized that support for WoL based on this patch became part of mainline two years ago! Great, but someone could have told me. So, no need to use this patch starting with 2.6.36.

Download link for Ubuntu 10.04: tulip_an983b_wol_lucid-2.6.32-22.patch
Download link for Ubuntu 8.04: tulip_an983b_wol_2.6.24.patch.gz

Using the patch

  1. Patch, compile, and install the kernel or module (see here for how to do this).
  2. Verify that the module recognizes the Ethernet adapter.

    Use dmesg to verify that the patched tulip module loaded and initialized the Ethernet adapter correctly. Look for the message which says that WOL support has been enabled:

    [ 40.298344] tulip_init_one: Enabled WOL support for AN983B
    [ 40.299020] tulip0: MII transceiver #1 config 3100 status 786d advertising 05e1.
    [ 40.306047] eth0: ADMtek Comet rev 17 at Port 0x3000, 00:30:05:65:34:fe, IRQ 19.

  3. Enable the events that may wakeup the computer.

    Wakeup events from the PCI bus must be allowed to wake up the computer. I had to enable the PCI0 device on my setup (use „echo PCI0 > /proc/acpi/wakeup“ to toggle between „enabled“ and „disabled“). Here is the contents of /proc/acpi/wakeup on my server after enabling the wake up events:

    Device S-state Status Sysfs node
    PCI0 S4 enabled no-bus:pci0000:00
    AGPB S4 enabled
    PCIH S4 enabled pci:0000:00:1e.0
    USB1 S4 disabled pci:0000:00:1d.0
    USB2 S4 disabled pci:0000:00:1d.1
    USB3 S4 disabled pci:0000:00:1d.2
    USB4 S4 disabled pci:0000:00:1d.7
    AC97 S4 disabled pci:0000:00:1f.5
    MC97 S4 disabled
    KEYB S1 disabled pnp:00:07
    PS2M S1 disabled
    COM1 S1 disabled pnp:00:0a
    COM2 S1 disabled

    Enabling PCI0 also enables AGPB and PCIH in my setup.

  4. Enable wakeup for the PCI device.

    Note: This seems to be necessary for Ubuntu 10.04 only. I did not do this under Ubuntu 8.04.

    Wakeup must be enabled for the respective PCI device. In my case, this is device 02:01.0 (see lspci output above):

    > echo enabled > /sys/bus/pci/devices/0000\:02\:01.0/power/wakeup
    > echo enabled > /sys/bus/pci/devices/0000\:00\:1e.0/power/wakeup

    The second line is for the PCI bridge the Ethernet card is attached to. I don’t think this is really necessary, though. The kernel seems to enable wakeup for the PCI bridge automatically when suspending.

  5. Enable the wakeup event on the Ethernet adapter.

    WoL is disabled by default. Thus ethtool should show the following:

    > ethtool eth0
    Settings for eth0:
    Supports Wake-on: pg
    Wake-on: d

    Enable wake on magic packet:

    > ethtool -s eth0 wol g
    > ethtool eth0
    Settings for eth0:
    Supports Wake-on: pg
    Wake-on: g

  6. Prevent unloading of network modules when going into standby.

    Note: This does not seem to be necessary for Ubuntu 10.04 anymore.

    I use pm-utils for hibernating to ram. Unfortunately, it unloads the network driver modules before suspending, i.e. the suspend/resume functions in the network driver are never called. In my setup, I don’t need to unload any modules when hibernating. Therefore, I commented the calls to both the shell functions suspend_modules and unload_network in /usr/lib/pm-utils/sleep.d/50modules:

    case „$1“ in
    # suspend_modules
    # unload_network

    Note that /usr/lib/pm-utils/sleep.d/10NetworkManager might do similar things for Ethernet adapters that are controlled by Network Manager.

  7. Suspend the system.

    Use /usr/sbin/pm-suspend to suspend the computer. The link on your Ethernet adapter should stay up. Send a magic packet from another computer to the MAC address of the Ethernet adapter (fingers crossed) …

Schreib einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *