Skip to content

wifi: brcmfmac: AWDL support for the BCM4387 (AirDrop link layer) - #11

Closed
brentkearney wants to merge 7 commits into
omacom:asahifrom
brentkearney:feat/awdl-bcm4387
Closed

brentkearney wants to merge 7 commits into
omacom:asahifrom
brentkearney:feat/awdl-bcm4387

Conversation

@brentkearney

@brentkearney brentkearney commented Sep 22, 2026 •

Copy link
Copy Markdown

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 brcmfmac card. On firmware that does not implement AWDL, the failure comes at interface creation. Recovering from a wedged firmware means unloading brcmfmac, 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 network with any result, working or not.

What the patches do

patch what
0001 Create an AWDL interface: the firmware accepts BRCMF_INTERFACE_TYPE_AWDL.
0002 AWDL-specific netdev ops for awdl0.
0003 Return firmware error codes from the vendor command, instead of flattening them.
0004 Create the interface with no BSSID and no requested index, which is what the firmware wants.
0005 Do not tear the AWDL netdev down from the P2P path.
0007 Translate AWDL data frames at the awdl0 boundary.
0008 Tolerate a txstatus for a freed flowring, rather than dereferencing it.

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

git clone https://github.com/omacom/linux -b feat/awdl-bcm4387
cd linux
zcat /proc/config.gz > .config
make olddefconfig
make -j"$(nproc)" Image modules dtbs
sudo make modules_install

Reboot into the new kernel, then bring the interface up. The helpers in omdrop-awdl do this for you; by hand it is a vendor command plus the usual interface setup, and userspace/awdl-up in that repo is the reference.

Check it came up

Each line is the signal that the layer beneath it worked.

check meaning
ip link show awdl0 The firmware accepted the interface-creation request.
ip -6 addr show awdl0 shows a link-local address The netdev is up and addressable.
A peer appears in omdrop peers Action frames from other devices are reaching the host.
omdrop peers -n returns a name A full TLS /Discover round trip completed over AWDL.

When it doesn't come up

No awdl0 after the vendor command. The firmware did not accept BRCMF_INTERFACE_TYPE_AWDL. Support on other chipsets is unverified; report the device id and firmware error.

awdl0 exists 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 awdl0 from 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

Hardware tested running Linux Wi-Fi chip WLAN PCI ID
MacBook Pro, 16-inch (2021), M1 Pro Broadcom BCM4387 14e4:4433

Probably Works

These models have identified Broadcom BCM4387 hardware, but have not been tested with the AWDL patched drivers:

Hardware Apple chip Wi-Fi chip
MacBook Air (2020) M1 BCM4378
MacBook Pro, 13-inch (2020) M1 BCM4378
Mac mini (2020) M1 BCM4378
iMac, 24-inch (2021), two-port and four-port models M1 BCM4378
MacBook Pro, 13-inch (2022) M2 BCM4378

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.

Hardware Apple chip Wi-Fi chip
MacBook Pro, 14-inch (2021) M1 Pro / M1 Max BCM4387
MacBook Pro, 16-inch (2021) M1 Max BCM4387
Mac Studio (2022) M1 Max / M1 Ultra BCM4387
MacBook Air, 13-inch (2022) M2 BCM4387
MacBook Air, 15-inch (2023) M2 BCM4387
Mac mini (2023) M2 / M2 Pro BCM4388
MacBook Pro, 14-inch (early 2023) M2 Pro / M2 Max BCM4388
MacBook Pro, 16-inch (early 2023) M2 Pro / M2 Max BCM4388
Mac Studio (2023) M2 Max / M2 Ultra BCM4388
Mac Pro (2023), tower and rack M2 Ultra BCM4388 reported; see caveat below

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:

  • Exact Mac model/year and Apple chip.
  • WLAN device ID from lspci -nn (BCM4378: 14e4:4425; BCM4387: 14e4:4433; BCM4388: 14e4:4434).
  • Kernel version, tested patch revision, and Wi-Fi firmware version when available.
  • Which steps work: creating awdl0, finding peers, resolving names, sending, and receiving. Distinguish a working interface from a completed transfer.
  • Relevant errors or logs, with personal data and credentials removed.

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-patch files, 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 -g reports 0 errors, 0 warnings, 0 checks across all seven patches.

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]>
@brentkearney

Copy link
Copy Markdown
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)
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