1: 036050c8afe9 = 1: 80199fdfd8b5 wifi: brcmfmac: move the interface_create definitions to fwil_types.h 2: 289004021746 = 2: f4065cd5c8c4 wifi: brcmfmac: detect AWDL support of the firmware 3: 1e96f476e05d ! 3: 9e3fb0fc3321 wifi: brcmfmac: create and remove the AWDL interface @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile: brcmfmac-objs += \  ## drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new) ##  @@ -+// SPDX-License-Identifier: GPL-2.0 ++// SPDX-License-Identifier: ISC  +/* -+ * Copyright (c) 2026 André Eikmeyer  ++ * Copyright (c) 2026 Andre Eikmeyer   + *  + * AWDL interface of the Apple firmware of the BCM4364 and BCM4377.  + * @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  + bool own, late = false;  +  + spin_lock(&awdl->lock); -+ own = (awdl->adding || awdl->abandoned) && ifp->ndev && ++ own = awdl->adding && ifp->ndev &&  + ether_addr_equal(ifp->mac_addr, awdl->mac); -+ if (own && awdl->adding) { ++ late = !own && awdl->abandoned && ifp->ndev && ++ ether_addr_equal(ifp->mac_addr, awdl->abandoned_mac); ++ if (own) {  + ifp->awdl = true;  + strscpy(ifp->ndev->name, "awdl%d", IFNAMSIZ);  + /* Keeps udev from giving it a name from the bus path */ @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  + awdl->ifp = ifp;  + awdl->adding = false;  + complete(&awdl->if_event); -+ } else if (own) { ++ } else if (late) {  + awdl->abandoned = false; -+ late = true;  + }  + spin_unlock(&awdl->lock);  +  + /* brcmf_awdl_add() gave up on this interface */  + if (late)  + brcmf_awdl_drop_if(drvr, ifp); -+ return own; ++ return own || late;  +}  +  +/* @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  +/* The firmware interface index of the AWDL interface must be free */  +static bool brcmf_awdl_ifidx_used(struct brcmf_pub *drvr)  +{ ++ struct brcmf_if *ifp;  + int i;  + -+ for (i = 1; i < BRCMF_MAX_IFS; i++) -+ if (drvr->iflist[i] && drvr->iflist[i]->ifidx == BRCMF_AWDL_IFIDX) ++ for (i = 1; i < BRCMF_MAX_IFS; i++) { ++ ifp = drvr->iflist[i]; ++ if (ifp && ifp->ifidx == BRCMF_AWDL_IFIDX)  + return true; ++ }  + return false;  +}  + @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  + struct brcmf_if *pri = brcmf_get_ifp(drvr, 0);  + struct wl_interface_create_v3 req = {};  + struct brcmf_if *ifp; -+ long left = 0;  + int err;  +  + ASSERT_RTNL(); @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  + spin_lock(&awdl->lock);  + ether_addr_copy(awdl->mac, mac);  + awdl->adding = true; -+ awdl->abandoned = false;  + reinit_completion(&awdl->if_event);  + spin_unlock(&awdl->lock);  + @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  + err = brcmf_fil_iovar_data_get(pri, "interface_create", &req,  + sizeof(req));  + if (!err) -+ left = wait_for_completion_timeout(&awdl->if_event, -+ BRCMF_AWDL_IF_TIMEOUT); ++ wait_for_completion_timeout(&awdl->if_event, ++ BRCMF_AWDL_IF_TIMEOUT);  +  + spin_lock(&awdl->lock);  + awdl->adding = false;  + ifp = awdl->ifp;  + /* The firmware created the interface, its event may still come */ -+ if (!err && !ifp) ++ if (!err && !ifp) {  + awdl->abandoned = true; ++ ether_addr_copy(awdl->abandoned_mac, mac); ++ }  + spin_unlock(&awdl->lock);  +  + if (err) {  + bphy_err(drvr, "AWDL interface_create failed: %d\n", err);  + return err;  + } -+ if (!left || !ifp) { ++ if (!ifp) {  + bphy_err(drvr, "no interface event for the AWDL interface\n");  + return -ETIMEDOUT;  + } @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c (new)  ## drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h (new) ##  @@ -+/* SPDX-License-Identifier: GPL-2.0 */ ++/* SPDX-License-Identifier: ISC */  +/* -+ * Copyright (c) 2026 André Eikmeyer  ++ * Copyright (c) 2026 Andre Eikmeyer   + *  + * AWDL interface of the Apple firmware, see awdl.c  + */ @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h (new)  +/**  + * struct brcmf_awdl - AWDL interface of a device.  + * -+ * @lock: protects @mac, @adding, @abandoned, @removing and @ifp against the -+ * firmware event worker. Changes of @ifp also hold RTNL and the wiphy -+ * mutex. ++ * @lock: protects @mac, @adding, @abandoned, @abandoned_mac, @removing and ++ * @ifp against the firmware event worker. Changes of @ifp also hold RTNL ++ * and the wiphy mutex.  + * @if_event: completed by the interface event of the AWDL interface.  + * @mac: MAC address requested for the AWDL interface.  + * @adding: interface_create was sent, its interface event is awaited.  + * @abandoned: the interface event did not come in time, an AWDL interface -+ * that shows up later is removed again. ++ * with @abandoned_mac that shows up later is removed again. ++ * @abandoned_mac: MAC address of the abandoned AWDL interface.  + * @removing: interface_remove was sent, its interface event is awaited.  + * @detached: the device goes away, no new AWDL interface is created.  + * @ifp: the AWDL interface, NULL when there is none. @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h (new)  + u8 mac[ETH_ALEN];  + bool adding;  + bool abandoned; ++ u8 abandoned_mac[ETH_ALEN];  + bool removing;  + bool detached;  + struct brcmf_if *ifp; 4: 24ef96633cbb = 4: 155cf9566caf wifi: brcmfmac: add the AWDL data path 5: ee5ae7b24862 ! 5: f0b27f918a9c wifi: brcmfmac: add vendor commands for AWDL @@ Commit message go to.  The driver sets the other AWDL parameters in the order and with the - values macOS 15.4.1 sets on a MacBookAir 9,1. awdl_opmode fails while + values macOS 15.4.1 sets on a MacBookAir9,1. awdl_opmode fails while the firmware does not know a new master yet, so every refresh sends the frames and the synchronization state, and SET_FRAMES and SET_SYNC report only the errors of their own part. The BCM4364 firmware traps with the SDB form of slot_bss while the station is on 5 GHz, the new quirk AWDL_NO_SDB selects the other form.  + When the firmware removes the AWDL interface on its own, a work item + removes it on the host with RTNL and the wiphy mutex held and then sends + AWDL_STOPPED. + Tested-by: Yossef Osman  Tested-by: Aditya Garg  Signed-off-by: Andre Eikmeyer  @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: static const u8 brcmf_a  + 0x00, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x6e, 0x00,  +};  + -+/* Header of awdl_oob_af_auto, the AWDL BSSID at 8, followed by the TLV length */ ++/* Header of awdl_oob_af_auto, the AWDL BSSID at 8, then the TLV length */  +static const u8 brcmf_awdl_oob_hdr[] = {  + 0xff, 0xff, 0xff, 0xff, 0xd8, 0x40, 0x00, 0x00,  + 0x00, 0x25, 0x00, 0xff, 0x94, 0x73, 0xff, 0xff, @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: static const u8 brcmf_a  +#define BRCMF_AWDL_PEER_IES_MAX 128  +  +static void brcmf_awdl_ctrl_work(struct work_struct *work); ++static void brcmf_awdl_remove_work(struct work_struct *work);  +static void brcmf_awdl_aftx_work(struct wiphy *wiphy, struct wiphy_work *work);  +static void brcmf_awdl_settle_work(struct wiphy *wiphy,  + struct wiphy_work *work); @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: static const u8 brcmf_a  + spin_lock_init(&awdl->lock);  + init_completion(&awdl->if_event);  + INIT_WORK(&awdl->ctrl_work, brcmf_awdl_ctrl_work); ++ INIT_WORK(&awdl->remove_work, brcmf_awdl_remove_work);  + wiphy_delayed_work_init(&awdl->aftx_work, brcmf_awdl_aftx_work);  + wiphy_delayed_work_init(&awdl->settle_work, brcmf_awdl_settle_work); } @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: void brcmf_awdl_attach(  bool brcmf_awdl_if_added(struct brcmf_pub *drvr, struct brcmf_if *ifp) { -@@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: bool brcmf_awdl_if_removed(struct brcmf_pub *drvr, struct brcmf_if *ifp) - awdl->ifp = NULL; +@@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: bool brcmf_awdl_if_added(struct brcmf_pub *drvr, struct brcmf_if *ifp) +  + /* + * Called from the firmware event worker before an interface is removed. +- * Returns true if the removal of the AWDL interface was requested by +- * brcmf_awdl_del(), which then removes it. When the firmware removes the +- * AWDL interface on its own, it is forgotten here and removed by the caller. ++ * Returns true for the AWDL interface, which is then removed by ++ * brcmf_awdl_del() when it requested the removal, or by ++ * brcmf_awdl_remove_work() when the firmware removed it on its own. + */ + bool brcmf_awdl_if_removed(struct brcmf_pub *drvr, struct brcmf_if *ifp) + { + struct brcmf_awdl *awdl = &drvr->awdl; +- bool requested = false; ++ bool requested = false, own = false; +  + if (!ifp->awdl) + return false; +  + spin_lock(&awdl->lock); + if (awdl->ifp == ifp) { ++ own = true; + requested = awdl->removing; + if (requested) + complete(&awdl->if_event); + else +- awdl->ifp = NULL; ++ awdl->fw_removed = true; } spin_unlock(&awdl->lock);  - if (!requested) -+ if (!requested) { - brcmf_proto_configure_addr_mode(drvr, ifp->ifidx, - ADDR_INDIRECT); -+ brcmf_awdl_send_result(drvr, BRCMF_VNDR_EVTS_AWDL_STOPPED, -+ -ENOLINK, NULL); -+ } - return requested; +- brcmf_proto_configure_addr_mode(drvr, ifp->ifidx, +- ADDR_INDIRECT); +- return requested; ++ /* The event worker cannot take RTNL and the wiphy mutex, which ++ * brcmf_awdl_add() and brcmf_awdl_del() hold while they wait for it ++ */ ++ if (own && !requested) ++ schedule_work(&awdl->remove_work); ++ return own; }  + /* The firmware interface index of the AWDL interface must be free */ +@@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_add(struct brcmf_pub *drvr, const u8 *mac, + return 0; + } +  ++/* Stops AWDL and removes the AWDL interface in the firmware */ ++static int brcmf_awdl_fw_del(struct brcmf_pub *drvr, struct brcmf_if *ifp) ++{ ++ int err; ++ ++ brcmf_fil_iovar_int_set(ifp, "awdl", 0); ++ err = brcmf_fil_iovar_data_set(ifp, "interface_remove", NULL, 0); ++ if (!err && !wait_for_completion_timeout(&drvr->awdl.if_event, ++ BRCMF_AWDL_IF_TIMEOUT)) { ++ bphy_err(drvr, "no interface event for the AWDL removal\n"); ++ err = -ETIMEDOUT; ++ } ++ return err; ++} ++ + /** + * brcmf_awdl_del() - remove the AWDL interface. + * +@@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_add(struct brcmf_pub *drvr, const u8 *mac, + * + * Called with RTNL and the wiphy mutex held. Deletes the flowrings of the + * AWDL interface, stops AWDL and removes the interface in the firmware and on +- * the host. ++ * the host. After the firmware removed it on its own, only the host side is ++ * removed. + * + * Return: 0 or a negative error code. + */ +@@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_del(struct brcmf_pub *drvr) + { + struct brcmf_awdl *awdl = &drvr->awdl; + struct brcmf_if *ifp; ++ bool fw_removed; + int err; +  + ASSERT_RTNL();  @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_del(struct brcmf_pub *drvr) if (!ifp) return -ENOENT; @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_del(stru netif_tx_disable(ifp->ndev); /* Deletes the flowrings of all peers */ brcmf_proto_configure_addr_mode(drvr, ifp->ifidx, ADDR_INDIRECT); +- brcmf_fil_iovar_int_set(ifp, "awdl", 0); +  + spin_lock(&awdl->lock); +- awdl->removing = true; ++ fw_removed = awdl->fw_removed; ++ awdl->removing = !fw_removed; + reinit_completion(&awdl->if_event); + spin_unlock(&awdl->lock); +  +- err = brcmf_fil_iovar_data_set(ifp, "interface_remove", NULL, 0); +- if (!err && !wait_for_completion_timeout(&awdl->if_event, +- BRCMF_AWDL_IF_TIMEOUT)) { +- bphy_err(drvr, "no interface event for the AWDL removal\n"); +- err = -ETIMEDOUT; +- } ++ /* After the firmware removed it, only the host side is left */ ++ err = fw_removed ? 0 : brcmf_awdl_fw_del(drvr, ifp); +  + spin_lock(&awdl->lock); + awdl->removing = false; ++ awdl->fw_removed = false; + awdl->ifp = NULL; + spin_unlock(&awdl->lock); +   @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_decap(struct sk_buff *skb) return 0; } @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: int brcmf_awdl_decap(st  +}  +  +/* ++ * Removes the AWDL interface on the host after the firmware removed it on ++ * its own. It holds RTNL and the wiphy mutex like brcmf_awdl_del(), so the ++ * vendor commands and the delayed works never see the interface go away. ++ * AWDL_STOPPED is sent once the interface is gone. ++ */ ++static void brcmf_awdl_remove_work(struct work_struct *work) ++{ ++ struct brcmf_awdl *awdl = container_of(work, struct brcmf_awdl, ++ remove_work); ++ struct brcmf_pub *drvr = container_of(awdl, struct brcmf_pub, awdl); ++ bool gone; ++ ++ rtnl_lock(); ++ wiphy_lock(drvr->wiphy); ++ /* After a STOP, a suspend or the detach there is nothing left */ ++ spin_lock(&awdl->lock); ++ gone = awdl->ifp && awdl->fw_removed; ++ spin_unlock(&awdl->lock); ++ if (gone && !brcmf_awdl_del(drvr)) ++ brcmf_awdl_send_result(drvr, BRCMF_VNDR_EVTS_AWDL_STOPPED, ++ -ENOLINK, NULL); ++ wiphy_unlock(drvr->wiphy); ++ rtnl_unlock(); ++} ++ ++/*  + * Removes the AWDL interface before system sleep, with RTNL and the wiphy -+ * mutex held, while the firmware still takes commands. A queued operation is -+ * dropped. ++ * mutex held, while the firmware still takes commands. A queued START is ++ * answered with -ECANCELED, a queued STOP is done here.  + */  +void brcmf_awdl_suspend(struct brcmf_pub *drvr)  +{  + struct brcmf_awdl *awdl = &drvr->awdl; ++ enum brcmf_awdl_op op;  + int err;  +  + spin_lock(&awdl->lock); ++ op = awdl->op;  + awdl->op = BRCMF_AWDL_OP_NONE;  + spin_unlock(&awdl->lock); ++ if (op == BRCMF_AWDL_OP_START) ++ brcmf_awdl_send_result(drvr, BRCMF_VNDR_EVTS_AWDL_STARTED, ++ -ECANCELED, NULL);  + if (!awdl->ifp)  + return;  + err = brcmf_awdl_del(drvr); @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c: void brcmf_awdl_detach(  +  + /* A queued operation finds the device detached */  + cancel_work_sync(&awdl->ctrl_work); ++ cancel_work_sync(&awdl->remove_work); }  ## drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h ## @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h /** * struct brcmf_awdl - AWDL interface of a device. * +- * @lock: protects @mac, @adding, @abandoned, @abandoned_mac, @removing and +- * @ifp against the firmware event worker. Changes of @ifp also hold RTNL +- * and the wiphy mutex. ++ * @lock: protects @mac, @adding, @abandoned, @abandoned_mac, @removing, ++ * @fw_removed and @ifp against the firmware event worker. Changes of ++ * @ifp also hold RTNL and the wiphy mutex. + * @if_event: completed by the interface event of the AWDL interface. + * @mac: MAC address requested for the AWDL interface. + * @adding: interface_create was sent, its interface event is awaited.  @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h: struct sk_buff; + * with @abandoned_mac that shows up later is removed again. + * @abandoned_mac: MAC address of the abandoned AWDL interface. + * @removing: interface_remove was sent, its interface event is awaited. ++ * @fw_removed: the firmware removed the AWDL interface on its own, ++ * @remove_work removes it on the host. * @detached: the device goes away, no new AWDL interface is created. * @ifp: the AWDL interface, NULL when there is none. * @tx_seq: sequence number of the next data frame sent.  + * @ctrl_work: creates or removes the AWDL interface for the vendor commands,  + * which run without RTNL.  + * @op: operation of @ctrl_work, under @lock. ++ * @remove_work: removes the AWDL interface after the firmware removed it.  + * @start_mac: MAC address for %BRCMF_AWDL_OP_START.  + * @payload: awdl_payload with the TLVs of user space.  + * @payload_len: length of @payload. @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h: struct sk_buff; struct brcmf_awdl { spinlock_t lock; /* AWDL state against the event worker */  @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h: struct brcmf_awdl { + bool abandoned; + u8 abandoned_mac[ETH_ALEN]; + bool removing; ++ bool fw_removed; bool detached; struct brcmf_if *ifp; u16 tx_seq;  + struct work_struct ctrl_work;  + enum brcmf_awdl_op op; ++ struct work_struct remove_work;  + u8 start_mac[ETH_ALEN];  + u8 *payload;  + u32 payload_len; @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h  + * @BRCMF_VNDR_CMDS_AWDL_SET_SYNC: synchronize to the master of  + * %BRCMF_AWDL_ATTR_MASTER, %BRCMF_AWDL_ATTR_MASTER_METRIC and  + * %BRCMF_AWDL_ATTR_MASTER_DISTANCE. Without %BRCMF_AWDL_ATTR_MASTER the -+ * device is its own master. ++ * device is its own master. The firmware rejects a new master for a few ++ * seconds until it knows it, the command then fails with -%EBADE. The ++ * next %BRCMF_VNDR_CMDS_AWDL_SET_FRAMES or %BRCMF_VNDR_CMDS_AWDL_SET_SYNC ++ * sends the master again.  + * @BRCMF_VNDR_CMDS_AWDL_PEER_ADD: add the peer %BRCMF_AWDL_ATTR_ADDR, data  + * frames to it are sent from then on. %BRCMF_AWDL_ATTR_PEER_IES gives its  + * HT and VHT capabilities, sent again it updates them. @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h  + *  + * @BRCMF_VNDR_EVTS_UNSPEC: not used.  + * @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_AWDL_ATTR_STATUS and, on success, %BRCMF_AWDL_ATTR_IFINDEX. A ++ * start still queued before system sleep gets -%ECANCELED.  + * @BRCMF_VNDR_EVTS_AWDL_STOPPED: the AWDL interface was removed, with  + * %BRCMF_AWDL_ATTR_STATUS. After %BRCMF_VNDR_CMDS_AWDL_STOP and before  + * system sleep the status is 0 or the error of the removal. When the -+ * firmware removed the interface on its own it is -%ENOLINK. ++ * firmware removed the interface on its own it is -%ENOLINK, sent once ++ * the interface is gone on the host.  + * @BRCMF_VNDR_EVTS_LAST: number of vendor events.  + *  + * The value of an event is its index in the vendor events and its vendor 6: de7e6cdc6467 ! 6: 950a1f764a9d wifi: brcmfmac: pass AWDL frames and role changes to user space @@ Commit message  Tested-by: Yossef Osman  Tested-by: Aditya Garg  + Acked-by: Arend van Spriel  Signed-off-by: Andre Eikmeyer   ## drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c ## @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c: const struct nl80211_  ## drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h ##  @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h: enum brcmf_vndr_cmds { - * %BRCMF_AWDL_ATTR_STATUS. After %BRCMF_VNDR_CMDS_AWDL_STOP and before * system sleep the status is 0 or the error of the removal. When the - * firmware removed the interface on its own it is -%ENOLINK. + * firmware removed the interface on its own it is -%ENOLINK, sent once + * the interface is gone on the host.  + * @BRCMF_VNDR_EVTS_AWDL_FRAME: AWDL action frame received from  + * %BRCMF_AWDL_ATTR_ADDR, the frame body from the category on in  + * %BRCMF_AWDL_ATTR_FRAME.