From: Emery Hsin <emery.hsin@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <Sean.Wang@mediatek.com>, <jb.tsai@mediatek.com>,
<Quan.Zhou@mediatek.com>, <linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>,
Emery Hsin <emery.hsin@mediatek.com>
Subject: [PATCH 25/28] wifi: mt76: mt7925: apply FW-reported MLO link state
Date: Tue, 10 Nov 2026 11:12:41 +0800 [thread overview]
Message-ID: <20261110031244.369014-26-emery.hsin@mediatek.com> (raw)
In-Reply-To: <20261110031244.369014-1-emery.hsin@mediatek.com>
Handle the UNI STAREC event (0x0f) carrying the MLO link-state TLV
(tag 0x27) and fold the reported ACTIVE/INACTIVE state into
vif->active_links via ieee80211_set_active_links_async().
Signed-off-by: Emery Hsin <emery.hsin@mediatek.com>
---
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 +
.../net/wireless/mediatek/mt76/mt7925/main.c | 2 +
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 93 +++++++++++++++++++
.../wireless/mediatek/mt76/mt7925/mt7925.h | 23 +++++
drivers/net/wireless/mediatek/mt76/mt792x.h | 2 +
5 files changed, 121 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 2acaae9830fb..5c27285542ab 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1098,6 +1098,7 @@ enum {
MCU_UNI_EVENT_BSS_BEACON_LOSS = 0x0c,
MCU_UNI_EVENT_PS_SYNC = 0x0d,
MCU_UNI_EVENT_SCAN_DONE = 0x0e,
+ MCU_UNI_EVENT_STAREC = 0x0f,
MCU_UNI_EVENT_RDD_REPORT = 0x11,
MCU_UNI_EVENT_SAP = 0x1c,
MCU_UNI_EVENT_ROC = 0x27,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 00244a650464..2b1346044c5a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -484,6 +484,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mvif->sta.vif = mvif;
mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED;
mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC;
+ mvif->delay_inactive_links = U16_MAX;
mvif->valid_links = 0;
ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink,
@@ -1889,6 +1890,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
}
mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC;
+ mvif->delay_inactive_links = U16_MAX;
}
EXPORT_SYMBOL_GPL(mt7925_mac_sta_remove);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index b502f93166e5..2c2ab85180c4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -805,6 +805,96 @@ mt7925_mcu_handle_mbmc_event(struct mt792x_dev *dev, struct sk_buff *skb)
}
}
+/* Apply the link state reported by firmware to the vif active links. */
+static void
+mt7925_mcu_starec_link_state(struct mt792x_dev *dev, u16 wlan_idx,
+ struct mt7925_starec_mlo_link_state_tlv *state)
+{
+ struct mt792x_link_sta *mlink;
+ struct ieee80211_vif *vif;
+ struct mt792x_vif *mvif;
+ struct mt792x_sta *msta;
+ u16 old_links, new_links;
+ struct mt76_wcid *wcid;
+ u8 link_id;
+
+ rcu_read_lock();
+
+ wcid = mt76_wcid_ptr(dev, wlan_idx);
+ if (!wcid || !wcid->sta)
+ goto out;
+
+ mlink = container_of(wcid, struct mt792x_link_sta, wcid);
+ msta = mlink->sta;
+ if (!msta || !msta->vif)
+ goto out;
+
+ vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
+ if (!ieee80211_vif_is_mld(vif))
+ goto out;
+
+ mvif = (struct mt792x_vif *)vif->drv_priv;
+ link_id = wcid->link_id;
+ old_links = vif->active_links;
+
+ if (state->link_state == MT7925_MLO_LINK_STATE_ACTIVE) {
+ new_links = old_links | BIT(link_id);
+ mvif->delay_inactive_links |= BIT(link_id);
+ } else {
+ new_links = old_links & ~BIT(link_id);
+ }
+
+ /* Links held back from being deactivated, so a back-to-back
+ * INACTIVE+ACTIVE pair does not briefly leave the vif linkless.
+ * Never ask for an empty set: mac80211 drops such a request and the
+ * vif would stay out of sync with the firmware.
+ */
+ if (!new_links || !(new_links & mvif->delay_inactive_links)) {
+ mvif->delay_inactive_links &= ~BIT(link_id);
+ } else if (new_links != old_links) {
+ new_links &= mvif->delay_inactive_links;
+ mvif->delay_inactive_links = U16_MAX;
+ ieee80211_set_active_links_async(vif, new_links);
+ }
+
+out:
+ rcu_read_unlock();
+}
+
+static void
+mt7925_mcu_starec_event(struct mt792x_dev *dev, struct sk_buff *skb)
+{
+ struct mt7925_uni_starec_event *event;
+ struct tlv *tlv;
+ u16 wlan_idx;
+ u32 tlv_len;
+
+ if (skb->len < sizeof(struct mt7925_mcu_rxd) + sizeof(event->hdr))
+ return;
+
+ skb_pull(skb, sizeof(struct mt7925_mcu_rxd));
+ event = (struct mt7925_uni_starec_event *)skb->data;
+ wlan_idx = le16_to_cpu(event->hdr.wlan_idx);
+
+ tlv = (struct tlv *)event->tlv;
+ tlv_len = skb->len - sizeof(event->hdr);
+
+ mt7925_for_each_tlv(tlv, tlv_len) {
+ switch (le16_to_cpu(tlv->tag)) {
+ case MT7925_STAREC_TAG_MLO_LINK_STATE:
+ if (le16_to_cpu(tlv->len) <
+ sizeof(struct mt7925_starec_mlo_link_state_tlv))
+ break;
+
+ mt7925_mcu_starec_link_state(dev, wlan_idx,
+ (void *)tlv);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
static void
mt7925_mcu_uni_rx_unsolicited_event(struct mt792x_dev *dev,
struct sk_buff *skb)
@@ -841,6 +931,9 @@ mt7925_mcu_uni_rx_unsolicited_event(struct mt792x_dev *dev,
case MCU_UNI_EVENT_BSS_IS_ABSENCE:
mt7925_p2p_mcu_bss_is_absence_event(dev, skb);
break;
+ case MCU_UNI_EVENT_STAREC:
+ mt7925_mcu_starec_event(dev, skb);
+ break;
case MCU_UNI_EVENT_RSSI_MONITOR:
mt7925_mcu_rssi_monitor_event(dev, skb);
break;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index d829eb9686c7..5a46a6a45e0c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -133,6 +133,29 @@ struct mt7925_uni_beacon_loss_event {
struct mt7925_beacon_loss_tlv beacon_loss;
} __packed;
+/* STAREC event: MLO link state */
+#define MT7925_STAREC_TAG_MLO_LINK_STATE 0x27
+
+/* link_state values */
+#define MT7925_MLO_LINK_STATE_ACTIVE 0
+#define MT7925_MLO_LINK_STATE_INACTIVE 1
+
+struct mt7925_starec_mlo_link_state_tlv {
+ __le16 tag;
+ __le16 len;
+ u8 link_state;
+ u8 reason;
+ u8 pad[2];
+} __packed;
+
+struct mt7925_uni_starec_event {
+ struct {
+ __le16 wlan_idx;
+ u8 pad[2];
+ } __packed hdr;
+ u8 tlv[];
+} __packed;
+
struct mt7925_uni_rssi_monitor_event {
__le16 tag;
__le16 len;
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 96d4dfe8ee45..f1a0a296ae0f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -220,6 +220,8 @@ struct mt792x_vif {
struct mt792x_phy *phy;
bool roc_join_held; /* join ROC kept until the STA is authorized */
u16 valid_links;
+ /* Links held back from being deactivated, U16_MAX when none is held. */
+ u16 delay_inactive_links;
u8 deflink_id;
enum mt792x_mlo_pm_state mlo_pm_state;
--
2.45.2
next prev parent reply other threads:[~2026-11-10 3:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 3:12 [PATCH 00/28] wifi: mt76: mt7925: add MLO hybrid and EMLSR support Emery Hsin
2026-11-10 3:12 ` [PATCH 01/28] wifi: mt76: mt7925: fix the basic rate sent in the STA phy TLV Emery Hsin
2026-11-10 3:12 ` [PATCH 02/28] wifi: mt76: mt7925: fix MLO sub-link memory leak on disconnect Emery Hsin
2026-11-10 3:12 ` [PATCH 03/28] wifi: mt76: mt792x: turn chip_cap bits into an enum of bit positions Emery Hsin
2026-11-10 3:12 ` [PATCH 04/28] wifi: mt76: mt792x: use named constants for the DBDC band Emery Hsin
2026-11-10 3:12 ` [PATCH 05/28] wifi: mt76: use named constants for the HT secondary channel offset Emery Hsin
2026-11-10 3:12 ` [PATCH 06/28] wifi: mt76: mt7925: factor out mt7925_mac_link_sta_free_wcid() Emery Hsin
2026-11-10 3:12 ` [PATCH 07/28] wifi: mt76: mt792x: add a gated mt792x_mcu_set_dev_active() helper Emery Hsin
2026-11-10 3:12 ` [PATCH 08/28] wifi: mt76: mt792x: route DEV (de)activation through mt792x_mcu_set_dev_active() Emery Hsin
2026-11-10 3:12 ` [PATCH 09/28] wifi: mt76: mt7925: deactivate the DEV and BSS on disconnect Emery Hsin
2026-11-10 3:12 ` [PATCH 10/28] wifi: mt76: mt7925: reactivate the DEV before (re)connect, scan and off-channel Emery Hsin
2026-11-10 3:12 ` [PATCH 11/28] wifi: mt76: mt7925: parse the FW hybrid-MLO third-link band limit Emery Hsin
2026-11-10 3:12 ` [PATCH 12/28] wifi: mt76: mt7925: gate EMLSR by AP vendor OUI allowlist Emery Hsin
2026-11-10 3:12 ` [PATCH 13/28] wifi: mt76: mt7925: support multi-link hybrid/EMLSR remain-on-channel Emery Hsin
2026-11-10 3:12 ` [PATCH 14/28] wifi: mt76: mt7925: describe the whole MLD in the STA/BSS MLD TLVs Emery Hsin
2026-11-10 3:12 ` [PATCH 15/28] wifi: mt76: mt7925: assign a per-MLD firmware link index Emery Hsin
2026-11-10 3:12 ` [PATCH 16/28] wifi: mt76: mt7925: share the primary OMAC across MLO links Emery Hsin
2026-11-10 3:12 ` [PATCH 17/28] wifi: mt76: mt7925: carry the STA decap offload to later links Emery Hsin
2026-11-10 3:12 ` [PATCH 18/28] wifi: mt76: mt7925: split link sta add into alloc and commit phases Emery Hsin
2026-11-10 3:12 ` [PATCH 19/28] wifi: mt76: mt7925: publish every link before sending any STA_REC Emery Hsin
2026-11-10 3:12 ` [PATCH 20/28] wifi: mt76: mt7925: add mt7925_mcu_add_bss_sec() helper Emery Hsin
2026-11-10 3:12 ` [PATCH 21/28] wifi: mt76: mt7925: only refresh the SEC tag when setting the first key Emery Hsin
2026-11-10 3:12 ` [PATCH 22/28] wifi: mt76: mt7925: add mt7925_set_links_key_iter() helper Emery Hsin
2026-11-10 3:12 ` [PATCH 23/28] wifi: mt76: mt7925: bring up all MLO links on authorization Emery Hsin
2026-11-10 3:12 ` [PATCH 24/28] wifi: mt76: mt7925: skip re-adding the primary MLD BSS_INFO in chanctx ops Emery Hsin
2026-11-10 3:12 ` Emery Hsin [this message]
2026-11-10 3:12 ` [PATCH 26/28] wifi: mt76: mt7925: remap hybrid-MLO TX to the primary link OMAC Emery Hsin
2026-11-10 3:12 ` [PATCH 27/28] wifi: mt76: mt7925: clear the MLD BSS tag on deactivate Emery Hsin
2026-11-10 3:12 ` [PATCH 28/28] wifi: mt76: mt7925: add hm_alg_ctrl debugfs to override the MLO link plan Emery Hsin
2026-11-25 11:04 ` [PATCH 00/28] wifi: mt76: mt7925: add MLO hybrid and EMLSR support Felix Fietkau
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=20261110031244.369014-26-emery.hsin@mediatek.com \
--to=emery.hsin@mediatek.com \
--cc=Quan.Zhou@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=jb.tsai@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
/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