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 4/7] wifi: brcmfmac: create and remove the AWDL interface
Date: Sun, 22 Nov 2026 21:09:29 +0100 [thread overview]
Message-ID: <20261122200931.2090372-4-arend.vanspriel@broadcom.com> (raw)
In-Reply-To: <20261104151547.70333-5-dev@deq.rocks>
On Wed, 4 Nov 2026 16:15:44 +0100, Andre Eikmeyer <dev@deq.rocks> wrote:
> Firmware with AWDL support takes an interface of type AWDL from
> interface_create. The host gives the MAC address, the firmware
> interface index 2 and the AWDL BSSID 00:25:00:ff:94:73. The firmware
> answers with an interface event like for any other interface.
>
> The AWDL interface lives outside cfg80211. Add brcmf_awdl_add() and
> brcmf_awdl_del(), called with RTNL and the wiphy mutex held, which
> create and remove it together with a network device "awdl%d":
>
> - The interface events of the AWDL interface complete a wait in
> brcmf_awdl_add() and brcmf_awdl_del() instead of going to the
> cfg80211 handler. A vif_event armed for a P2P or AP interface at the
> same time stays with that interface. When the firmware removes the
> AWDL interface on its own, the event worker removes it as before.
> - The network device gets its own net_device_ops with open, stop and
> start_xmit before it is registered. The firmware filters AWDL traffic
> itself.
> - brcmf_net_attach() and brcmf_net_detach() also register and
> unregister a network device outside cfg80211 with RTNL held.
> - brcmf_awdl_add() needs the AWDL feature and a free firmware
> interface index 2.
> - The AWDL interface uses direct addressing like an AP, every peer
> gets its own flowrings. brcmf_awdl_del() deletes them before it
> stops AWDL and removes the interface.
> - The AWDL interface is removed in the cfg80211 suspend callback while
> the firmware still takes commands.
>
> 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/Makefile | 3 +-
> .../broadcom/brcm80211/brcmfmac/awdl.c | 268 ++++++++++++++++++
> .../broadcom/brcm80211/brcmfmac/awdl.h | 47 +++
> .../broadcom/brcm80211/brcmfmac/cfg80211.c | 6 +
> .../broadcom/brcm80211/brcmfmac/core.c | 59 +++-
> .../broadcom/brcm80211/brcmfmac/core.h | 7 +
> .../broadcom/brcm80211/brcmfmac/fweh.c | 17 ++
> 7 files changed, 398 insertions(+), 9 deletions(-)
> create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c
> create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h
[...]
> @@ -0,0 +1,268 @@
> +/**
> + * brcmf_awdl_add() - create the AWDL interface.
> + *
> + * @drvr: device.
> + * @mac: MAC address of the AWDL interface.
> + * @ndev: set to the network device of the AWDL interface.
> + *
> + * Called with RTNL and the wiphy mutex held. The interface uses the firmware interface index 2
> + * and the AWDL BSSID 00:25:00:ff:94:73, which the host passes to the
> + * firmware. Return: 0 or a negative error code.
> + */
> +int brcmf_awdl_add(struct brcmf_pub *drvr, const u8 *mac,
> + struct net_device **ndev)
Return: has to start its own line for kernel-doc. The kdoc check reports
no description for the return value of brcmf_awdl_add().
[...]
> @@ -0,0 +1,268 @@
> + if (!err)
> + left = wait_for_completion_timeout(&awdl->if_event,
> + BRCMF_AWDL_IF_TIMEOUT);
> +
> + spin_lock(&awdl->lock);
> + awdl->adding = false;
> + ifp = awdl->ifp;
> + spin_unlock(&awdl->lock);
> +
> + if (err) {
> + bphy_err(drvr, "AWDL interface_create failed: %d\n", err);
> + return err;
> + }
> + if (!left || !ifp) {
> + bphy_err(drvr, "no interface event for the AWDL interface\n");
> + return -ETIMEDOUT;
> + }
> +
> + /* Like an AP, AWDL sends to each peer through its own flowrings */
When the interface event does not arrive within BRCMF_AWDL_IF_TIMEOUT,
brcmf_awdl_add() returns -ETIMEDOUT but the interface stays created in
the firmware. If its event comes in later, adding is cleared so
brcmf_awdl_if_added() does not take it. brcmf_add_if() has stored the
ifp in iflist with interface index 2 by then and nothing removes it.
brcmf_awdl_ifidx_used() makes every following brcmf_awdl_add() fail
with -EBUSY until the device is detached.
On this path send interface_remove, and drop an ifp that shows up
afterwards with brcmf_awdl_drop_if() instead of leaving it in iflist.
[...]
> @@ -0,0 +1,268 @@
> + }
> +
> + /* Like an AP, AWDL sends to each peer through its own flowrings */
> + brcmf_proto_configure_addr_mode(drvr, ifp->ifidx, ADDR_DIRECT);
> + err = brcmf_net_attach(ifp, true);
> + if (err) {
> + spin_lock(&awdl->lock);
> + awdl->ifp = NULL;
> + spin_unlock(&awdl->lock);
> + brcmf_awdl_drop_if(drvr, ifp);
> + return err;
> + }
> + brcmf_dbg(INFO, "%s: AWDL interface, bsscfgidx %d ifidx %d\n",
> + ifp->ndev->name, ifp->bsscfgidx, ifp->ifidx);
> + *ndev = ifp->ndev;
> + return 0;
The other brcmfmac interfaces get SET_NETDEV_DEV(ndev,
wiphy_dev(cfg->wiphy)) in cfg80211.c. The AWDL net_device has no parent
device, so /sys/class/net/awdl0/device does not exist and the interface
is not tied to the bus device in sysfs. udev and network managers that
match on bus path, driver or parent device do not find it. Add
SET_NETDEV_DEV(ifp->ndev, wiphy_dev(drvr->wiphy)) before
brcmf_net_attach().
[...]
> @@ -642,6 +640,42 @@ static const struct net_device_ops brcmf_netdev_ops_pri = {
> .ndo_set_rx_mode = brcmf_netdev_set_multicast_list
> };
>
> +static int brcmf_awdl_netdev_open(struct net_device *ndev)
> +{
> + struct brcmf_if *ifp = netdev_priv(ndev);
> +
> + if (ifp->drvr->bus_if->state != BRCMF_BUS_UP)
> + return -EAGAIN;
> +
> + /* The firmware runs AWDL, the link is there while it exists */
> + netif_carrier_on(ndev);
> + netif_start_queue(ndev);
> + return 0;
> +}
> +
> +static int brcmf_awdl_netdev_stop(struct net_device *ndev)
> +{
> + netif_stop_queue(ndev);
> + netif_carrier_off(ndev);
> + return 0;
> +}
> +
> +/*
> + * The AWDL interface gets no multicast list and no MAC address change, the
> + * firmware filters AWDL traffic itself.
> + */
> +static const struct net_device_ops brcmf_netdev_ops_awdl = {
> + .ndo_open = brcmf_awdl_netdev_open,
> + .ndo_stop = brcmf_awdl_netdev_stop,
> + .ndo_start_xmit = brcmf_netdev_start_xmit,
> +};
> +
> +static bool brcmf_netdev_is_brcmf(struct net_device *ndev)
> +{
> + return ndev->netdev_ops == &brcmf_netdev_ops_pri ||
> + ndev->netdev_ops == &brcmf_netdev_ops_awdl;
> +}
> +
> int brcmf_net_attach(struct brcmf_if *ifp, bool locked)
> {
> struct brcmf_pub *drvr = ifp->drvr;
brcmf_inetaddr_changed() finds the interface by its net_device, so an
IPv4 address on the AWDL interface reaches the ARP offload code. With
arp_version 1 that code uses the primary interface and adds the AWDL
address to its arp_hostip table, so the firmware answers ARP for the
AWDL address on the station interface. Skip ifp->awdl in
brcmf_inetaddr_changed().
It looks like this is the/another reason for the arpoe/ndoe patch [1]
sent. At least for the ARP disabling part.
Regards,
Arend
[1] https://patchwork.kernel.org/project/linux-wireless/patch/20261118123933.74517-1-dev@deq.rocks/
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 [this message]
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
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-4-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®