From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Andre Eikmeyer <dev@deq.rocks>
Cc: arend.vanspriel@broadcom.com, linux-wireless@vger.kernel.org,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
linux-kernel@vger.kernel.org,
Yossef Osman <Yossef.Osman@proton.me>,
Aditya Garg <aditya.garg@linux.dev>
Subject: Re: [PATCH 6/7] wifi: brcmfmac: add vendor commands for AWDL
Date: Sun, 22 Nov 2026 21:09:30 +0100 [thread overview]
Message-ID: <20261122200931.2090372-5-arend.vanspriel@broadcom.com> (raw)
In-Reply-To: <20261104151547.70333-7-dev@deq.rocks>
On Wed, 4 Nov 2026 16:15:46 +0100, Andre Eikmeyer <dev@deq.rocks> wrote:
> AWDL election, peer discovery and services run in user space. The
> firmware sends and receives the AWDL frames and the data once the host
> has set its AWDL parameters. Add vendor commands of the Broadcom OUI on
> the primary interface for that:
>
> - AWDL_START creates the AWDL interface with the given MAC address and
> starts AWDL with the given TLVs. AWDL_STOP stops it and removes the
> interface. Registering and unregistering the network device needs
> RTNL, vendor commands run with the wiphy lock only. Both commands
> therefore run in a work item and report their result with the vendor
> events AWDL_STARTED and AWDL_STOPPED.
> - AWDL_SET_FRAMES replaces the TLVs the firmware sends, the TLVs of
> awdl_payload and awdl_oob_af_auto. The driver adds the headers.
> - AWDL_SET_SYNC sets the master to synchronize to, with its metric and
> the distance to it. Leaving out the master makes the device its own
> master.
> - AWDL_PEER_ADD and AWDL_PEER_DEL add and remove a peer data frames go
> to. AWDL_PEER_ADD takes the HT and VHT capabilities elements of the
> peer, which macOS builds from the AWDL TLVs of the peer and passes in
> awdl_peer_op.
>
> The other firmware parameters of AWDL are set by the driver in the
> order and with the values macOS 15.4.1 sets on the BCM4377 of a
> MacBookAir9,1. The BCM4364 gets slot_bss without SDB,
> its firmware traps with the SDB form while the station is on 5 GHz.
> Some parameters change 500 ms and 5 s after the start.
>
> The AWDL interface is removed before system sleep with an AWDL_STOPPED
> event.
>
> Tested-by: Yossef Osman <Yossef.Osman@proton.me>
> Tested-by: Aditya Garg <aditya.garg@linux.dev>
> Signed-off-by: Andre Eikmeyer <dev@deq.rocks>
> ---
> .../broadcom/brcm80211/brcmfmac/awdl.c | 586 +++++++++++++++++-
> .../broadcom/brcm80211/brcmfmac/awdl.h | 53 ++
> .../broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +-
> .../broadcom/brcm80211/brcmfmac/vendor.c | 78 +++
> .../broadcom/brcm80211/brcmfmac/vendor.h | 86 +++
> 5 files changed, 804 insertions(+), 4 deletions(-)
[...]
> @@ -53,10 +58,123 @@ static const u8 brcmf_awdl_bssid[ETH_ALEN] = {
> +};
> +
> +/* awdl_election_tree: the master at 0x0f, its metric at 0x15, distance 0x19 */
> +#define BRCMF_AWDL_ELECTION_ADDR 0x0f
> +#define BRCMF_AWDL_ELECTION_METRIC 0x15
> +#define BRCMF_AWDL_ELECTION_DISTANCE 0x19
> +static const u8 brcmf_awdl_election_tree[] = {
> + 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00,
> + 0x05, 0xba, 0x00, 0x00, 0x01, 0x03, 0x04, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00,
> +};
> +
> +/*
These tables are patched at fixed offsets (0x0f, 0x15 and 0x19 here, and
in slot_bss, awdl_opmode and awdl_peer_op). Say in a comment that they
are copied from the macOS trace and not otherwise documented, and name
the firmware versions they were verified on.
[...]
> @@ -335,6 +455,461 @@ int brcmf_awdl_decap(struct sk_buff *skb)
> +/* Sets a firmware parameter of the AWDL interface, errors are only logged */
> +static void brcmf_awdl_set(struct brcmf_if *ifp, const char *name,
> + const void *data, u32 len)
> +{
> + int err;
> +
> + err = brcmf_fil_iovar_data_set(ifp, name, data, len);
> + if (err)
> + brcmf_dbg(INFO, "AWDL %s: %d\n", name, err);
> +}
> +
brcmf_awdl_set() only logs a failure at INFO level, so AWDL_START
reports status 0 when the firmware rejected awdl, awdl_config or
slot_bss and AWDL is not running. Return the error from
brcmf_awdl_set() and fail brcmf_awdl_enable() on the iovars AWDL needs
(at least awdl, awdl_config and slot_bss). User space then gets the
error in AWDL_STARTED and the interface is removed again. The same
goes for brcmf_awdl_refresh(), which makes SET_FRAMES and SET_SYNC
return 0 whatever the firmware says.
[...]
> @@ -335,6 +455,461 @@ int brcmf_awdl_decap(struct sk_buff *skb)
> + u8 buf[sizeof(brcmf_awdl_slot_bss)];
> + u8 *s0, *s1;
> + int i;
> +
> + memcpy(buf, brcmf_awdl_slot_bss, sizeof(buf));
> + /* The BCM4364 firmware traps with the SDB form while the station is
> + * on 5 GHz
> + */
> + if (drvr->bus_if->chip == BRCM_CC_4364_CHIP_ID) {
> + buf[BRCMF_AWDL_SLOT_SDB] = BRCMF_AWDL_SLOT_SDB_OFF;
> + for (i = 0; i < BRCMF_AWDL_SLOTS; i++) {
> + s0 = buf + BRCMF_AWDL_SLOT_SLICE0 + 2 * i;
> + s1 = buf + BRCMF_AWDL_SLOT_SLICE1 + 2 * i;
> + if (!get_unaligned_le16(s0))
> + memcpy(s0, s1, 2);
> + memset(s1, 0, 2);
> + }
> + }
> + brcmf_awdl_set(drvr->awdl.ifp, "slot_bss", buf, sizeof(buf));
> +}
> +
Chip checks like this one are not preferred. feature.c already
carries the per-chip and per-firmware handling (quirks). Set a quirk
for the BCM4364 there and test it here.
[...]
> @@ -335,6 +455,461 @@ int brcmf_awdl_decap(struct sk_buff *skb)
> +int brcmf_awdl_vndr_stop(struct wiphy *wiphy, struct wireless_dev *wdev,
> + const void *data, int len)
> +{
> + struct nlattr *tb[BRCMF_AWDL_ATTR_MAX + 1];
> + struct brcmf_pub *drvr;
> + struct brcmf_awdl *awdl;
> +
> + drvr = brcmf_awdl_vndr_parse(wiphy, data, len, tb);
> + if (IS_ERR(drvr))
> + return PTR_ERR(drvr);
> + awdl = &drvr->awdl;
> + if (awdl->detached)
> + return -ENODEV;
> + if (!awdl->ifp && awdl->op != BRCMF_AWDL_OP_START)
> + return -ENOENT;
> +
> + spin_lock(&awdl->lock);
> + awdl->op = BRCMF_AWDL_OP_STOP;
> + spin_unlock(&awdl->lock);
> + schedule_work(&awdl->ctrl_work);
> + return 0;
> +}
AWDL_STOP while AWDL_START is still queued replaces the pending
operation, there is a single op slot. The START is dropped without an
AWDL_STARTED event, and the STOP finds no interface and reports
AWDL_STOPPED with -ENOENT. User space that sends START and STOP back to
back gets a start that is never answered. Reject the STOP with -EBUSY
while a START is pending, or keep both operations pending and run them
in order.
[...]
> @@ -8,12 +8,97 @@
>
> +/**
> + * enum brcmf_vndr_evts - vendor events of the Broadcom OUI
> + *
> + * @BRCMF_VNDR_EVTS_AWDL_STARTED: result of %BRCMF_VNDR_CMDS_AWDL_START with
> + * %BRCMF_AWDL_ATTR_STATUS and, on success, %BRCMF_AWDL_ATTR_IFINDEX.
> + * @BRCMF_VNDR_EVTS_AWDL_STOPPED: the AWDL interface was removed, after
> + * %BRCMF_VNDR_CMDS_AWDL_STOP or before system sleep, with
> + * %BRCMF_AWDL_ATTR_STATUS.
> + * @BRCMF_VNDR_EVTS_LAST: number of vendor events.
> + *
> + * The value of an event is its index in the vendor events and its vendor
> + * subcommand.
> + */
> +enum brcmf_vndr_evts {
> + BRCMF_VNDR_EVTS_AWDL_STARTED,
> + BRCMF_VNDR_EVTS_AWDL_STOPPED,
> + BRCMF_VNDR_EVTS_LAST
> +};
> +
> +/**
> + * enum brcmf_awdl_attrs - attributes of the AWDL vendor commands and events
> + *
> + * @BRCMF_AWDL_ATTR_ADDR: MAC address, of the AWDL interface or of a peer.
> + * @BRCMF_AWDL_ATTR_PAYLOAD: AWDL TLVs for the firmware parameter
> + * awdl_payload.
> + * @BRCMF_AWDL_ATTR_OOB: AWDL TLVs for the firmware parameter
> + * awdl_oob_af_auto.
> + * @BRCMF_AWDL_ATTR_MASTER: MAC address of the master (u8[6]).
Two points on this interface. The vendor commands are the exception
agreed for AWDL, which makes this header ABI that cannot change after
merge:
- AWDL_STOPPED is only sent for AWDL_STOP and before suspend. When the
firmware removes the AWDL interface on its own
(brcmf_awdl_if_removed() in patch 4) the net_device disappears and
user space is not told. Send AWDL_STOPPED in that case as well.
- brcmf_vndr_cmds and brcmf_awdl_attrs start with an UNSPEC entry,
brcmf_vndr_evts does not, so AWDL_STARTED is subcommand 0. Add an
UNSPEC entry here, and describe BRCMF_AWDL_ATTR_UNSPEC in the
kernel-doc, the kdoc check warns about it.
Regards,
Arend
next prev parent reply other threads:[~2026-11-22 20:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 15:15 [PATCH 0/7] wifi: brcmfmac: AWDL for AirDrop on Apple T2 Macs Andre Eikmeyer
2026-11-04 15:15 ` [PATCH 1/7] wifi: brcmfmac: match firmware capabilities as whole words Andre Eikmeyer
2026-11-05 17:33 ` Arend van Spriel
2026-11-06 7:07 ` André Eikmeyer
2026-11-04 15:15 ` [PATCH 2/7] wifi: brcmfmac: move the interface_create definitions to fwil_types.h Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel
2026-11-04 15:15 ` [PATCH 3/7] wifi: brcmfmac: detect AWDL support of the firmware Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel
2026-11-04 15:15 ` [PATCH 4/7] wifi: brcmfmac: create and remove the AWDL interface Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel
2026-11-04 15:15 ` [PATCH 5/7] wifi: brcmfmac: add the AWDL data path Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel
2026-11-04 15:15 ` [PATCH 6/7] wifi: brcmfmac: add vendor commands for AWDL Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel [this message]
2026-11-04 15:15 ` [PATCH 7/7] wifi: brcmfmac: pass AWDL frames and role changes to user space Andre Eikmeyer
2026-11-22 20:09 ` Arend van Spriel
2026-11-08 15:41 ` [PATCH 0/7] wifi: brcmfmac: AWDL for AirDrop on Apple T2 Macs Arend van Spriel
2026-11-08 18:20 ` André Eikmeyer
2026-11-11 14:28 ` Aditya Garg
2026-11-18 10:52 ` Arend van Spriel
2026-11-22 20:08 ` Arend van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122200931.2090372-5-arend.vanspriel@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=Yossef.Osman@proton.me \
--cc=aditya.garg@linux.dev \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=dev@deq.rocks \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®