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 19/28] wifi: mt76: mt7925: publish every link before sending any STA_REC
Date: Tue, 10 Nov 2026 11:12:35 +0800 [thread overview]
Message-ID: <20261110031244.369014-20-emery.hsin@mediatek.com> (raw)
In-Reply-To: <20261110031244.369014-1-emery.hsin@mediatek.com>
The MLD setup TLV is built from msta->link[], so a STA_REC sent while
later links are missing carries a partial MLD. Publish every link first,
then program them primary first. A single link to MLD upgrade re-adds the
primary with a new wcid on the reused deflink storage.
Signed-off-by: Emery Hsin <emery.hsin@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 60 +++++++++++++++++--
1 file changed, 56 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index b497e904d4b5..a93df77da269 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1212,6 +1212,9 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
unsigned int link_id;
int err = 0;
+ /* Publish every link before sending any STAREC, so the MLD setup TLV
+ * describes the whole MLD.
+ */
for_each_set_bit(link_id, &new_links, IEEE80211_MLD_MAX_NUM_LINKS) {
struct ieee80211_link_sta *link_sta;
struct mt792x_link_sta *mlink;
@@ -1220,6 +1223,26 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
if (msta->deflink_id == IEEE80211_LINK_UNSPECIFIED) {
mlink = &msta->deflink;
is_deflink = true;
+ } else if (link_id == msta->deflink_id &&
+ rcu_access_pointer(msta->link[link_id]) ==
+ &msta->deflink) {
+ /* Single link to MLD upgrade: re-add the primary with
+ * a new wcid so it binds to the granted band. This runs
+ * from the AUTHORIZE transition before mac80211 sets
+ * WLAN_STA_AUTHORIZED, so no data is being sent on this
+ * sta and reusing the deflink storage is safe.
+ */
+ link_sta = mt792x_sta_to_link_sta(vif, sta, link_id);
+ if (mt7925_mcu_sta_update(dev, link_sta, vif,
+ &msta->deflink, false,
+ MT76_STA_INFO_STATE_NONE))
+ dev_dbg(dev->mt76.dev,
+ "failed to tear down the old STA_REC\n");
+ mt7925_mac_link_sta_free_wcid(&dev->mt76,
+ &msta->deflink);
+ synchronize_rcu();
+ mlink = &msta->deflink;
+ is_deflink = true;
} else {
mlink = kzalloc_obj(*mlink);
if (!mlink) {
@@ -1236,8 +1259,17 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
err = mt7925_mac_link_sta_alloc(&dev->mt76, vif, link_sta,
mlink);
if (err) {
- if (!is_deflink)
+ if (!is_deflink) {
kfree(mlink);
+ } else if (link_id == msta->deflink_id) {
+ /* the upgrade path above already freed the
+ * deflink wcid, so unpublish it here instead
+ * of freeing the shared wcid a second time
+ */
+ rcu_assign_pointer(msta->link[link_id], NULL);
+ msta->valid_links &= ~BIT(link_id);
+ msta->deflink_id = IEEE80211_LINK_UNSPECIFIED;
+ }
break;
}
@@ -1246,13 +1278,33 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
if (is_deflink)
msta->deflink_id = link_id;
- /* published into msta->link[]; let the unwind path free it */
added_links |= BIT(link_id);
+ }
+
+ /* Configure the primary link first, it anchors the MLD. */
+ if (!err && msta->deflink_id != IEEE80211_LINK_UNSPECIFIED &&
+ (added_links & BIT(msta->deflink_id))) {
+ struct mt792x_link_sta *mlink =
+ mt792x_sta_to_link(msta, msta->deflink_id);
+ struct ieee80211_link_sta *link_sta =
+ mt792x_sta_to_link_sta(vif, sta, msta->deflink_id);
+
+ err = mt7925_mac_link_sta_add(&dev->mt76, vif, link_sta, mlink);
+ }
+ for_each_set_bit(link_id, &added_links,
+ IEEE80211_MLD_MAX_NUM_LINKS) {
+ struct ieee80211_link_sta *link_sta;
+ struct mt792x_link_sta *mlink;
- err = mt7925_mac_link_sta_add(&dev->mt76, vif, link_sta,
- mlink);
if (err)
break;
+ if (link_id == msta->deflink_id)
+ continue;
+
+ mlink = mt792x_sta_to_link(msta, link_id);
+ link_sta = mt792x_sta_to_link_sta(vif, sta, link_id);
+ err = mt7925_mac_link_sta_add(&dev->mt76, vif, link_sta,
+ mlink);
}
if (err && added_links)
--
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 ` Emery Hsin [this message]
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 ` [PATCH 25/28] wifi: mt76: mt7925: apply FW-reported MLO link state Emery Hsin
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-20-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