Repository navigation
usb: dock USB Ethernet Wake-on-LAN (cdc_ncm pattern filters + USB 3 per-function remote wake) - #1233
Closed
RyanTheTide wants to merge 2 commits into
Closed
RyanTheTide wants to merge 2 commits into
RyanTheTide wants to merge 2 commits into
Conversation
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_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, so its Ethernet could never wake the host from system sleep. 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 a resumed device leaves function suspend on all of them. The result 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 CDC Ethernet functional descriptor gives the number of power management pattern filters a function has (bNumberPowerFilters). While the function is suspended with remote wakeup enabled, it compares every received frame with the loaded patterns and wakes the host on a match (SET/GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER, which NCM takes over from ECM). cdc_ncm loaded none and had no ethtool WoL operations, so "ethtool -s <dev> wol g" failed and a dock's NCM Ethernet could not wake the host. Offer WAKE_MAGIC when the function has pattern filters and its configuration supports remote wakeup. Setting it enables wakeup on the USB device, as other USB Ethernet drivers do. Before a system sleep, load one pattern for each usual framing of a magic packet: UDP over IPv4 without options, the 0x0842 EtherType, and UDP over IPv6 without extension headers. The destination address is left out of the comparison, so broadcast and directed magic packets both match. Each pattern is read back with GET, since a pattern that does not fit leaves its filter inactive. The patterns are removed at resume, so they never affect runtime autosuspend. Only the generic cdc_ncm driver offers WoL. cdc_mbim and huawei_cdc_ncm share the ethtool operations but have no Ethernet descriptor and report no WoL support. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wake-on-LAN through a dock's USB Ethernet (CDC NCM), found on the J616s (M4 Pro) with a Plugable UD-ULTC4K dock (DisplayLink 17e9:6011). Before this,
ethtool enu1u2i5showed no Wake-on line and nothing on the network could wake the Mac.Two causes, two commits:
usb_enable_remote_wakeup()only armed interface 0 (it had a FIXME for exactly this case). On this dock interface 0 is the DisplayLink display function. The NCM Ethernet sits at interfaces 5-6 (DFU is 1, UAC2 audio is 2-4), so it was never armed. Now every function gets armed (each IAD's bFirstInterface, plus every interface outside an IAD) and every function gets disarmed on resume. The status of interface 0 is still the return value. Failures on other functions are only logged.bNumberPowerFilters 8. The driver now offerswol gwhen the function has pattern filters and the configuration supports remote wakeup. Before a system sleep it loads three magic-packet patterns: UDP/IPv4, EtherType 0x0842 and UDP/IPv6. The destination address is not compared. Each pattern is checked with GET_ETHERNET_PM_PATTERN_FILTER, and all of them are cleared (wLength 0) at resume, so runtime autosuspend is unchanged. cdc_mbim and huawei_cdc_ncm report no WoL.Default behaviour is unchanged: WoL is off until someone runs
ethtool -s <if> wol gor sets NetworkManager802-3-ethernet.wake-on-lan magic.Receipts
(J616s results follow in a comment below.)
🤖 Generated with Claude Code