Re: [PATCH 7/7] wifi: brcmfmac: pass AWDL frames and role changes to user space
From: Arend van Spriel
Date: Sun Nov 22 2026 - 15:10:14 EST
On Wed, 4 Nov 2026 16:15:47 +0100, Andre Eikmeyer <dev@deq.rocks> wrote:
> User space runs the AWDL election and peer discovery from the AWDL
> action frames other devices send. The firmware reports them with two
> events on the AWDL interface, ACTION_FRAME_RX and AWDL_EVENT (98). A
> header is in front of the frame. Its first 16 bits, high byte first,
> are its version: 1 is struct brcmf_rx_mgmt_data with 16 bytes, 2 has 24
> bytes. Both events come with either version. AWDL_EVENT carries a frame
> only with some of its status values. AWDL_ROLE (97) reports the AWDL
> role of the firmware in its status, 0 slave, 1 master not taking part
> in the election and 2 master.
>
> Register the two AWDL events when the firmware supports AWDL, so the
> event mask includes them. Pass every AWDL action frame (vendor specific
> category, OUI 00:17:f2, type 8) of the two events and the role changes
> to user space as the vendor events AWDL_FRAME and AWDL_ROLE. Other
> events of the AWDL interface are dropped as before.
>
> Tested-by: Yossef Osman <Yossef.Osman@xxxxxxxxx>
> Tested-by: Aditya Garg <aditya.garg@xxxxxxxxx>
> Signed-off-by: Andre Eikmeyer <dev@deq.rocks>
> ---
> .../broadcom/brcm80211/brcmfmac/awdl.c | 122 +++++++++++++++++-
> .../broadcom/brcm80211/brcmfmac/awdl.h | 4 +
> .../broadcom/brcm80211/brcmfmac/cfg80211.c | 1 +
> .../broadcom/brcm80211/brcmfmac/fweh.c | 8 +-
> .../broadcom/brcm80211/brcmfmac/fweh.h | 5 +
> .../broadcom/brcm80211/brcmfmac/vendor.c | 8 ++
> .../broadcom/brcm80211/brcmfmac/vendor.h | 12 ++
> 7 files changed, 151 insertions(+), 9 deletions(-)
[...]
> @@ -324,11 +324,13 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
> ifp = drvr->iflist[0];
> else
> ifp = drvr->iflist[emsg.bsscfgidx];
> - /* The AWDL interface has no vif, its events are not for
> - * the cfg80211 handlers
> + /* The AWDL interface has no vif, its events go to user
> + * space and not to the cfg80211 handlers
> */
> - if (ifp && ifp->awdl)
> + if (ifp && ifp->awdl) {
> + brcmf_awdl_fweh_event(ifp, &emsg, event->data);
> goto event_free;
> + }
>
> err = brcmf_fweh_call_event_handler(drvr, ifp, event->code,
> &emsg, event->data);
The return value of brcmf_awdl_fweh_event() is not used, and a
failure to allocate or fill the vendor event drops the frame without a
trace. A bphy_err() on those paths would show why frames are missing.
[...]
> @@ -94,7 +94,12 @@ struct brcmf_cfg80211_info;
> BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \
> BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \
> BRCMF_ENUM_DEF(TDLS_PEER_EVENT, 92) \
> + BRCMF_ENUM_DEF(AWDL_AW, 96) \
> + BRCMF_ENUM_DEF(AWDL_ROLE, 97) \
> + BRCMF_ENUM_DEF(AWDL_EVENT, 98) \
> BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127) \
> + BRCMF_ENUM_DEF(AWDL_STATS, 150) \
> + BRCMF_ENUM_DEF(SDB_STATE, 152) \
> BRCMF_ABSTRACT_ENUM_DEF(EXT_AUTH_REQ, 0) \
> BRCMF_ABSTRACT_ENUM_DEF(EXT_AUTH_FRAME_RX, 1) \
> BRCMF_ABSTRACT_ENUM_DEF(MGMT_FRAME_TXSTATUS, 2) \
These event codes are specific to the firmware used for the Apple
chips, but BRCMF_ENUM_DEF puts them in the common list where the same
numbers may mean something else on other firmware families. Use
abstract codes for them and translate them in the WCC vendor module,
like cyw/core.c does for EXT_AUTH_REQ:
1. fweh.h: replace the five BRCMF_ENUM_DEF() entries by
BRCMF_ABSTRACT_ENUM_DEF(AWDL_AW, 4), AWDL_ROLE 5, AWDL_EVENT 6,
AWDL_STATS 7 and SDB_STATE 8, after the existing abstract entries.
2. wcc/core.c: define BRCMF_WCC_E_AWDL_AW (96), _AWDL_ROLE (97),
_AWDL_EVENT (98), _AWDL_STATS (150) and _SDB_STATE (152) next to
BRCMF_WCC_E_LAST, which already covers them, and add a
struct brcmf_fweh_event_map brcmf_wcc_event_map with these five items
and n_items = 5.
3. wcc/core.c: set fweh->event_map = &brcmf_wcc_event_map in
brcmf_wcc_alloc_fweh_info().
4. Register the events from a new brcmf_wcc_register_event_handlers(),
set as .register_event_handlers in brcmf_wcc_ops, instead of
brcmf_awdl_register_events() called from wl_init_priv(). Keep the
BRCMF_FEAT_AWDL check there, and export brcmf_awdl_fweh_event() for
it. An abstract code is not range checked by brcmf_fweh_register()
on a vendor without an event map, so it must not be registered from
common code.
brcmf_awdl_fweh_event() itself keeps working, the event worker passes
it the abstract code.
Regards,
Arend