Skip to content

usb: dock USB Ethernet Wake-on-LAN (USB 3 per-function remote wake + cdc_ncm WoL for UD-ULTC4K) - #1235

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
usb/cdc-ncm-wol-2
Nov 8, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
usb/cdc-ncm-wol-2

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Wake-on-LAN through a dock's USB Ethernet, using the Plugable UD-ULTC4K (DisplayLink 17e9:6011, CDC NCM) on the J616s (M4 Pro). Before this change ethtool enu1u2i5 showed no Wake-on line, and a magic packet did not wake the Mac even with the dock's power/wakeup enabled. This supersedes #1233, whose pattern-filter approach the dock rejects (details below).

Commits

  1. usb: core: arm remote wakeup for every function of a USB 3 device. On USB 3 the host arms remote wake per function, with FUNCTION_SUSPEND sent to the first interface of each function. usb_enable_remote_wakeup() only armed interface 0 (the existing FIXME). On this dock interface 0 is the DisplayLink display function. DFU is interface 1, UAC2 audio is 2-4, and the NCM Ethernet is 5-6, so the Ethernet was never armed. With this commit every function is armed (each IAD's bFirstInterface, plus every interface outside an IAD) and every function is disarmed on resume. The status for interface 0 is still the return value. Failures on other functions are only logged.
  2. net: usb: cdc_ncm: Wake-on-LAN for the Plugable UD-ULTC4K dock. The function matches magic packets by itself. The new CDC_NCM_FLAG_WAKE_ON_MAGIC comes through driver_info->data, and the dock gets its own table entry ahead of the DisplayLink vendor match. get_wol/set_wol report WAKE_MAGIC and map it to the USB device's remote wakeup setting. Its CDC Ethernet descriptor says bNumberPowerFilters 8, but the device STALLs every SET/GET_ETHERNET_PM_PATTERN_FILTER request: usbfs probes of filters 0/1/2/7 with full, tiny and clear (wLength 0) patterns all stalled. GET_NTB_PARAMETERS and GET_NET_ADDRESS on the same interface work. So generic pattern-filter WoL cannot be used here.

Default behaviour is unchanged: WoL stays off until ethtool -s <if> wol g (or NM 802-3-ethernet.wake-on-lan magic) turns it on.

Receipts (J616s, 7.3.0-aurora-ethwol1 = fleet36 6cf0ab0 + these commits, config identical to fleet36, one-shot boot)

Every cycle was rtcwake -d rtc1 -m freeze with the RTC alarm armed as a fallback. The packet was sent from the host 20 s after the cycle started. The dock keyboard's own wakeup was disabled for the runs (it wakes itself; S2R6's quirk handles that) and restored afterwards.

Run Packet Result
magic x6 (wol g) wake.sh j616s eth (UDP 9/7 to 10.1.1.255, 255.255.255.255, 10.1.1.237) 6/6 woke after 20.5-20.7 s, packet-to-resume 0.44-0.55 s; wakeup source 2-1.2 + xhci-hcd.6.auto; NIC LOWER_UP with IPv4 0.03 s after resume
noise x5 (wol g) 6 unicast pings, random UDP to bcast/unicast port 9/137, mDNS 224.0.0.251, and a magic packet with the wrong MAC 5/5 slept until the RTC (wakeup source rtc)
control x3 (wol g) none 3/3 slept until the RTC
wol d magic slept until the RTC (wol d sets the dock's power/wakeup to disabled)
stock fleet36, dock power/wakeup=enabled via sysfs magic 0/2 woke: without commit 1 the Ethernet function is not armed

Also: ethtool -s wol d/g toggles /sys/bus/usb/devices/2-1.2/power/wakeup, wol u is refused (EINVAL), every suspend succeeded, AVC 0, 0 failed units, taint 0. The J616s was restored to fleet36 with the test kernel removed. Traces (own captures, not tainted): traces/usb/20261109-j616s-dock-eth-wol on the lab disk.

checkpatch --strict: one WARNING ('Plugable' is the brand name) and one CHECK (alignment, which matches the surrounding code).

🤖 Generated with Claude Code

A USB 3 device enables remote wakeup per function: the host arms each
function with SET_FEATURE(FUNCTION_SUSPEND) addressed to the first
interface of that function (USB 3.2, 9.4.9). usb_enable_remote_wakeup()
only ever sent it to interface 0 and carried a FIXME for devices whose
interface association descriptors show more than one function.

Docks are such devices. The Plugable UD-ULTC4K (DisplayLink 17e9:6011)
has a vendor display function at interface 0, DFU at 1, UAC2 audio at
2-4 and its CDC NCM Ethernet at 5-6. With wakeup enabled on the dock,
only the display function was armed, and a magic packet to its Ethernet
never woke the host from suspend-to-idle (0 of 2 on an M4 Pro MacBook
Pro; with this change 6 of 6 wake within 0.6 s).

Send FUNCTION_SUSPEND to the first interface of every function: the
bFirstInterface of each association, and every interface outside one.
Do the same when disarming, so that on resume every function leaves
function suspend. The status of the request to the first interface is
still the return value. A failure on another function is only logged,
so a device that rejects the request there keeps working as it did.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The Ethernet function of the Plugable UD-ULTC4K (DisplayLink 17e9:6011)
wakes the host on a magic packet addressed to it while it is suspended
with remote wakeup enabled. It does not wake on other traffic: unicast
pings, broadcast and multicast UDP, and a magic packet carrying another
station address all leave the host asleep. cdc_ncm had no ethtool WoL
operations, so "ethtool -s <dev> wol g" failed and NetworkManager's
wake-on-lan setting could not be applied.

Its CDC Ethernet descriptor lists 8 power management pattern filters,
but the function stalls SET and GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER
for every filter, so generic pattern-filter WoL cannot be used with it.
The magic packet match is built into the function.

Add CDC_NCM_FLAG_WAKE_ON_MAGIC for such functions, pass the driver_info
data of cdc_ncm devices on as their driver flags, and give the dock its
own entry ahead of the DisplayLink vendor match. With the flag,
get_wol/set_wol report WAKE_MAGIC and map it to the remote wakeup
setting of the USB device, which is what arms the match.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge gate: CI host-tests pass. Local tools/asahi/run-host-tests.py on the branch tree: 196/196 passed. Hardware proof on the J616s is in the description (the dock is attached only there). On the other Macs the hub.c change only alters the suspend path for multi-function USB 3 devices that have remote wakeup enabled. FLEET5 carries it, so its s2idle gate covers all four Macs.

@RyanTheTide
RyanTheTide merged commit 014973e into integration/aurora Nov 8, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the usb/cdc-ncm-wol-2 branch November 8, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant