Repository navigation
wifi: brcmfmac: AWDL support for the BCM4387 (AirDrop link layer) - #11
Closed
brentkearney wants to merge 7 commits into
Closed
brentkearney wants to merge 7 commits into
brentkearney wants to merge 7 commits into
Conversation
BCM4387 firmware implements AWDL (Apple Wireless Direct Link) and accepts
BRCMF_INTERFACE_TYPE_AWDL through interface_create, but nl80211 has no AWDL
iftype, so the interface cannot be created via add_virtual_intf(). Drive it
from a vendor command instead.
Creation is asynchronous, and has to be. nl80211 dispatches vendor commands
holding the wiphy mutex: NL80211_CMD_VENDOR sets NL80211_FLAG_NEED_WIPHY
without NL80211_FLAG_NO_WIPHY_MTX, unlike NL80211_CMD_NEW_INTERFACE which
sets NEED_RTNL | NO_WIPHY_MTX and takes the wiphy mutex itself, in that
order. Registering a netdev from the vendor command therefore deadlocks:
nl80211_vendor_cmd <- holds wiphy mutex
brcmf_awdl_add_vif
brcmf_net_attach
register_netdev <- takes RTNL
register_netdevice
call_netdevice_notifiers_info
cfg80211_netdev_notifier_call
mutex_lock <- wiphy mutex, already held
The task blocks in uninterruptible sleep while holding the RTNL, which
takes
down every netdev operation on the system; recovery needs a reboot. Using
cfg80211_register_netdevice() instead is not a fix either: it requires both
the RTNL and the wiphy mutex, and the vendor command holds only the latter,
so it trips ASSERT_RTNL and registers into an inconsistent state. Taking
the
RTNL explicitly would invert cfg80211's RTNL-then-wiphy order.
So brcmf_awdl_add_vif() only asks firmware for the interface and returns.
The netdev is registered later by brcmf_cfg80211_awdl_attach_pending(),
called from the fweh event worker, which runs on the system workqueue
holding neither lock. The vif event stays armed across the request because
brcmf_notify_vif_event() is what links the brcmf_if to the vif; without it
ndev->ieee80211_ptr is never set and cfg80211 ignores the netdev.
Userspace must wait for awdl0 to appear rather than assume the vendor
command created it.
Signed-off-by: Brent Kearney <[email protected]>
Bringing an AWDL interface up through brcmf_netdev_open() stops the firmware answering dcmds. Every subsequent command times out with -EIO, the infrastructure STA link drops with it, and only a brcmfmac reload recovers the device. The standard open path runs station bring-up against the interface: a toe_ol iovar query, brcmf_cfg80211_up(), and then the multicast and promisc configuration that ndo_set_rx_mode schedules via _brcmf_set_multicast_list(). An AWDL bsscfg is not a station, and issuing that sequence against one wedges the firmware control path. Give AWDL interfaces their own net_device_ops. brcmf_netdev_open_awdl() checks the bus is up, clears the 802.1x pending count, and leaves the carrier off, touching no firmware state. ndo_set_rx_mode is omitted entirely so the multicast worker never runs for these interfaces, and ndo_stop skips brcmf_cfg80211_down() for the same reason the open path skips brcmf_cfg80211_up(). awdl0 now comes up with the firmware still responsive and the STA link undisturbed. Signed-off-by: Brent Kearney <[email protected]>
brcmf_fil_cmd_data() collapses every firmware failure to -EBADE unless ifp->fwil_fwerr is set, so a userspace probe driving iovars through the Broadcom vendor dcmd passthrough cannot tell "no such iovar" from "bad argument" from "not up". Set fwil_fwerr around the call and log the raw BCME_* value. This makes the passthrough usable for firmware exploration: the same probe that previously reported EBADE for every failure now distinguishes BCME_BADOPTION, BCME_BUFTOOSHORT, BCME_NOTFOUND and BCME_NOTREADY. Signed-off-by: Brent Kearney <[email protected]>
brcmf_cfg80211_request_awdl_if() sent interface_create with MAC_USE alone: no BSSID and no requested interface index. On BCM4387 that yields an interface whose AWDL iovars stay unusable. Send flags 0x1a (MAC_USE | IF_INDEX_USE | BSSID_USE) with an explicit BSSID and if_index 2 instead. Firmware behaviour changes with those arguments: the interface is created at the requested index (wl0.2), awdl_peer_op returns data instead of BCME_NOMEM, and awdl_af_hdr, awdl_config and awdl_af_rssi are accepted where they previously were not. The three values are module parameters so they can be swept without rebuilding. Derive a MAC when the caller passes NULL rather than sending MAC_USE with an all-zero address. Signed-off-by: Brent Kearney <[email protected]>
nl80211 calls vendor commands holding the wiphy mutex and not the RTNL (NL80211_CMD_VENDOR sets NEED_WIPHY without NO_WIPHY_MTX). Calling brcmf_remove_interface() from brcmf_awdl_del_vif() therefore reaches cfg80211_close_dependents(), which asserts the RTNL: RTNL: assertion failed at net/wireless/core.c (419) cfg80211_close_dependents brcmf_remove_interface brcmf_awdl_del_vif brcmf_cfg80211_vndr_cmds_awdl_handler and then deadlocks the netdev layer against any concurrent RTNL holder, leaving NetworkManager and ip(8) unkillable in D state. Ask the firmware to drop the BSS and return. The BRCMF_E_IF_DEL event lands in brcmf_fweh_event_worker(), a plain work item holding neither lock, and brcmf_fweh_handle_if_event() removes the interface from there. This mirrors brcmf_awdl_add_vif(), which defers brcmf_net_attach() to the same worker for the same reason. Signed-off-by: Brent Kearney <[email protected]>
AWDL data frames on the air are 802.3 + LLC/SNAP (OUI 00:17:f2, protocol 0x0800) + a 6-byte data header (03 04 <seq16> 00 00) + the real ethertype. The kernel only speaks Ethernet II, so for is_awdl interfaces: - RX: brcmf_rx_eth_type_trans() strips the encapsulation in place before eth_type_trans(). It is called from both delivery paths -- brcmf_rx_hdrpull (BCDC) and the msgbuf RX completion (PCIe); a first attempt in hdrpull alone was dead code on PCIe. Frames that are already Ethernet II pass. - TX: brcmf_awdl_encap() wraps Ethernet II in the same header with a per-interface incrementing sequence; needed_headroom grows by 16. Frames that already carry a length field (raw AF_PACKET senders building the encapsulation themselves) pass untouched. Also log the destination MAC on each awdl0 TX completion so per-frame fates can be read per peer (unicast to a MAC without a firmware peer entry completes 0x0003 FW_TOSSED; with one, 0x0000 acked). With this, EUI-64 neighbour pinning and awdl_peer_op ADD, a remote peer completes TCP to us over firmware-native AWDL. Signed-off-by: Brent Kearney <[email protected]>
brcmf_msgbuf_delete_flowring() gives up on outstanding frames after ~75 ms and frees the ring; the firmware then completes them (tx_status 0x0006 EXPIRED) against a flow->rings[] slot that is already NULL. The awdl txstatus log line dereferenced it (oops in brcmf_flowring_ifidx_get from brcmf_msgbuf_process_rx on awdl-if destroy). Look the ring up only if it still exists, and reject a flowring id beyond max_flowrings before indexing. Signed-off-by: Brent Kearney <[email protected]>
Author
|
Closing: Omarchy Mac releases build from linux-aurora, so this series now targets aurora-silicon/linux: aurora-silicon/linux#24 |
chriskearney
referenced
this pull request
in chriskearney/aurora-linux
Sep 27, 2026
soc: apple: T8140 AOP services and CT817 ALS (reworked, 30 patches)
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.
Adds AWDL (Apple Wireless Direct Link), the link layer Apple devices use to talk to each other directly, to
brcmfmac, so AirDrop works natively on Macs whose Wi-Fi firmware implements it. The firmware does the AWDL work; these patches create the interface, route its frames, and stop the driver tearing it down.Userspace lives outside this tree: omdrop-awdl packages the root-side helpers, and omdrop-plugin is the Omarchy bar widget. Neither is required for the kernel side drivers.
Before you start
Verified on one chip: the BCM4387 (
14e4:4433). Other Apple Broadcom parts are plausible and untested; Intel, MediaTek, and Qualcomm cards cannot do this at all.Nothing here gates on chip id. The module builds and loads on any
brcmfmaccard. On firmware that does not implement AWDL, the failure comes at interface creation. Recovering from a wedged firmware means unloadingbrcmfmac, which takes the Wi-Fi link with it until it reloads, so test on a machine you can afford to drop off the network.Bringing up more chips is the main thing this PR is asking for. Report the id from
lspci -nn | grep -i networkwith any result, working or not.What the patches do
BRCMF_INTERFACE_TYPE_AWDL.awdl0.awdl0boundary.Numbering follows the source series; 0006 and 0009–0012 are debug instrumentation kept out of this PR, but if you want to add support for your chip, feel free to use them for development.
Try it
Reboot into the new kernel, then bring the interface up. The helpers in
omdrop-awdldo this for you; by hand it is a vendor command plus the usual interface setup, anduserspace/awdl-upin that repo is the reference.Check it came up
Each line is the signal that the layer beneath it worked.
ip link show awdl0ip -6 addr show awdl0shows a link-local addressomdrop peersomdrop peers -nreturns a name/Discoverround trip completed over AWDL.When it doesn't come up
No
awdl0after the vendor command. The firmware did not acceptBRCMF_INTERFACE_TYPE_AWDL. Support on other chipsets is unverified; report the device id and firmware error.awdl0exists but no peers appear. The interface is up and the firmware is not tracking neighbours. Check that the other device is actively advertising — a Mac advertises when its AirDrop window is open, an iPhone in short bursts.Peers appear but nothing connects. Firewall. The receiver needs TCP 8771 on
awdl0from an IPv6 link-local address.Wi-Fi drops when the interface is created. Firmware wedged. Reload
brcmfmac; a reboot always clears it.Hardware Compatibility
Known Works
14e4:4433Probably Works
These models have identified Broadcom BCM4387 hardware, but have not been tested with the AWDL patched drivers:
Also Probably Works, but Uncertain
These models have different Broadcom chips: BCM4387 and BCM4388. If they carry the same AWDL implementation in their firmware, the patched drivers should work. Please test.
Model/chip mapping sources: Asahi model and board inventory, Linux/Asahi WLAN PCI identifiers, and Apple-device-tree radio inventory. The M2 13-inch MacBook Pro uses BCM4378; the base-M2 Mac mini uses BCM4388. Do not infer the Wi-Fi chip from the Apple processor alone.
Feedback wanted—especially from BCM4378 and BCM4388 owners. Please report successes and failures here, including:
lspci -nn(BCM4378:14e4:4425; BCM4387:14e4:4433; BCM4388:14e4:4434).awdl0, finding peers, resolving names, sending, and receiving. Distinguish a working interface from a completed transfer.Testing other BCM4387 models is useful too. Please follow the Wi-Fi-disruption warning above; untested does not mean supported or known broken.
Contributing
Patch iteration, the userspace helpers, and the instrumentation left out of this series live in omdrop-awdl. Its CONTRIBUTING.md covers how to send a kernel change so your authorship survives into this series — the patches are carried there as
git format-patchfiles, and editing one of those files puts the wrong name on the commit that lands here.Tested-by:from a chip other than the BCM4387 is the most useful thing anyone can add.Checks
scripts/checkpatch.pl --strict -greports 0 errors, 0 warnings, 0 checks across all seven patches.