Re: [PATCH 4/7] wifi: brcmfmac: create and remove the AWDL interface
From: Arend van Spriel
Date: Sun Nov 22 2026 - 15:10:00 EST
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@xxxxxxxxx>
> Tested-by: Aditya Garg <aditya.garg@xxxxxxxxx>
> 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/