[PATCH ath-next v3 0/7] wifi: ath12k: fix MLO active-links handling

From: Miaoqing Pan

Date: Wed Dec 02 2026 - 02:59:09 EST


mac80211 calls drv_change_vif_links() and drv_change_sta_links() for
both valid-links and active-links changes. ath12k does not distinguish
between the two, causing WARN_ON/incorrect teardown in change_vif_links(),
inconsistent vdev state in the chanctx callbacks, and silent
firmware miss in change_sta_links().

This series derives link object lifetime from vif->valid_links and
sta->valid_links, which mac80211 updates before calling the driver,
instead of from the active-links sets. A STA link vdev keeps running when
its link is deactivated. A STA also keeps the link vif of a link removed
by ML reconfiguration until disconnect, as firmware does not support
deleting the vdev of a single link while the ML association is up. The
active/inactive link state is programmed to firmware with
WMI_MLO_LINK_SET_ACTIVE_CMDID, sent to each device that holds vdevs of
the STA, and only when it differs from the state last programmed.

Patch 1 adds WMI infrastructure: the response event struct,
WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT tag, and the event handler
registered in ath12k_wmi_op_rx(). The handler only parses and logs
the event at this point; delivery to the waiter is wired up in patch 7.

Patch 2 sets CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP and
CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP for FORCE_ACTIVE_INACTIVE, so that
firmware replaces the force bitmaps instead of accumulating them. It also
copies the AP MLD address into the command, and fixes the
CRTL_F_DYNC_FORCE_LINK_NUM typo.

Patch 3 fixes ath12k_mac_op_change_vif_links() so that link vif lifetime
follows vif->valid_links. A link that is only deactivated keeps its link
vif. For a STA, a link removed from valid_links keeps its link vif as
well: ML reconfiguration deactivates the link first, so the removal is
not reported to the driver. A disconnect (valid_links == 0) removes all
remaining link vifs. Links that are not in vif->valid_links have no
bss_conf and are skipped in the change_chanctx iterators.

Patch 4 makes ath12k_mac_get_vif_up() skip links without a channel
context. A deactivated link keeps its vdev up in firmware but has
released its channel context, so it must not be used to derive the
target pdev. The WARN_ON() in ath12k_mac_get_target_pdev_id_from_vif()
is kept.

Patch 5 stops clearing is_started for a STA vdev in
unassign_vif_chanctx(). The vdev is not stopped there, so the flag now
keeps matching the firmware state. assign_vif_chanctx() then compares the
new channel with started_chandef: if it is unchanged nothing is done.
Otherwise the vdev is restarted on the new channel, or stopped and started
if it is not up. Station removal clears is_started once the STA vdev has
been stopped, so that a reconnect on targets with vdev_start_delay starts
the vdev again.

Patch 6 fixes the bounds checks in ath12k_mac_mlo_sta_set_link_active().
The vdev_bitmap and inactive_vdev_bitmap arrays are sized by
WMI_MLO_VDEV_BITMAP_SZ, but the checks compared against
WMI_MLO_LINK_NUM_SZ. Both are 2 today, so there is no functional change.
The checks now use the constant of the array they guard.

Patch 7 makes ath12k_mac_op_change_sta_links() create link STAs for
sta->valid_links that are not yet in links_map. Link STA removal is
still left to STA removal, as firmware does not support it. Once the STA
is authorized, a link holding a channel context is active, and a link
with a link STA and link vif but no channel context is inactive. Links
that are no longer in vif->valid_links are left out. The result is
compared with ahvif->fw_active_links and ahvif->fw_inactive_links, and
WMI_MLO_LINK_SET_ACTIVE_CMDID is sent only when it differs. It is sent
to each device that holds vdevs of the STA, with that device's links,
and the driver waits for each device's response, except in the
INACTIVE_LINK_NUM case, which is sent without waiting. Before anything
is sent, all devices are checked. If a device holds some of the STA's
links but none of them is active, firmware cannot deactivate all links
of a device, so the update is skipped without sending any command to
any device, and the cached state is left unchanged. If the device
crashes while a request is pending,
ath12k_core_pre_reconfigure_recovery() releases the waiter before it
takes the wiphy lock.

Patch 7 depends on patches 1, 2, 3 and 5: it needs the response event
from patch 1, the ap_mld_addr argument from patch 2, link vifs that
survive deactivation from patch 3, and a STA link vdev that stays
started across deactivation from patch 5. Patches 1-6 each apply to the
base on their own, and the whole series applies in order.

Changes in v3:
- Patch 3: for a STA, keep the link vifs of links removed from
vif->valid_links until disconnect. ML reconfiguration deactivates a
link before it removes it from valid_links, so the removal is not
reported through change_vif_links(). v2 removed the stale link vif
on a later, unrelated active-link change, deleting the vdev of a
single link while the ML association was up. Also skip links not in
vif->valid_links in the change_chanctx iterators, and correct the
commit message: old_links/new_links are the active links also for a
valid-links change.
- Patch 7: leave links that are not in vif->valid_links out of
ath12k_mac_mlo_sta_sync_active_links(). A removed link has no
channel context and was counted as inactive, which could make the
sync skip the update.
- Patches 1, 2, 4-6: no changes, rebased onto the latest ath-next.

Changes in v2:
- Patch 7: in ath12k_mac_mlo_sta_sync_active_links(), check all devices
before sending any command. If a device would be left with no active
link, skip the whole update, log it, and return 0 instead of failing
with -EOPNOTSUPP. v1 checked each device while sending, so devices
handled before the failing one had already been programmed, but the
cached state was not updated.
- Patches 1-6: no code changes, rebased onto the latest ath-next.

Miaoqing Pan (7):
wifi: ath12k: add WMI response handling for MLO link set active
command
wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set
active
wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link
updates
wifi: ath12k: skip links without channel context in
ath12k_mac_get_vif_up()
wifi: ath12k: restart STA link vdev on chanctx assign if channel
changed
wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check
wifi: ath12k: handle MLO active link updates

drivers/net/wireless/ath/ath12k/core.c | 15 +
drivers/net/wireless/ath/ath12k/core.h | 25 ++
drivers/net/wireless/ath/ath12k/mac.c | 362 ++++++++++++++++++++++---
drivers/net/wireless/ath/ath12k/wmi.c | 54 +++-
drivers/net/wireless/ath/ath12k/wmi.h | 11 +-
5 files changed, 432 insertions(+), 35 deletions(-)


base-commit: 92adc530e9b0c1f680a3b78326e069b55ccf2029
--
2.34.1