Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795019088; b=YvVje1LWLNp5glmY+5yGHkof8/ovBpoHTBeIRZj9RyF4WNpuKSbZljivuSHyW0ABlNh4 Q8KoFIo8bb1t4gI5jKOo68f9nNWkNZBkX9dgu+xjajkhlIzcUAEcopa8s9SLy0gF2t+1z qSRzzG/sMpqWVE7KRYj8+EIEzOsopvl8v/Ov15iiyVi71db3/z1GGjKsMqmUku/+gqi8K bBnl+HxZvNvSaQsZkax+E/i60nE7R7+ELGDEjD2VqX9yOTJUiLLkMfAvtLhgtD46Rb1JQ tkzuY9mdUiBPmX4ZmScelJfYBNPDyq1ChAbgZBg4IPj51HjGI0L6o/cR/91+TA346ow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795019088; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=sKLSijjOHnrDO2oLktMmh6DzJbkUOXZBpA32YxQD7hk=; b=S+N1oTPx9r/bfPz071GswEuATQthcpA5TdjUoVg1yCj8BAMAaLnSUo1Squq8pP68iF+W WTraA4NaucUpgS4mZp1ZtlfcBlc+PF6VJRO9Nv2r1BIoGaTFELkphGHzTyLn5wUAxju8K J9WdeYt7lgekuo+8m2oUkw5t64+exINBGCwqhVQKw4rzZh1Suon/Hkb/KGqWrroyC2bhs wS4b4XkfRq7BMKLStxmPvV5ZR/8510dmk3ijSWyVHy5bMefHzo4DkQVWkn2iJDCRCHbV9 4z89J89FcUGshRqWaJYa3ZjrMWxW26ySipLvndgqetF/X2fQG+S8keFD0EPqAStHgzA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yT06j87R; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3504D606A31C; Wed, 18 Nov 2026 16:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yT06j87R Received: by smtp.kernel.org (Postfix) with ESMTPSA id 899341F000C4; Wed, 18 Nov 2026 16:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795019088; bh=sKLSijjOHnrDO2oLktMmh6DzJbkUOXZBpA32YxQD7hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yT06j87R3WRsdB2rOd3P86ySisZx0QJ+9bOEPR1xzpQ5h5M96h3R1lgMitzMFJCSj +2Eth6G/7g+CFSLz5p5X/hLurR+N/1377dHRrAstLiOjznjIMbqFqsib5ZzTJwPNoA mye6T/NZGI9O170bGw6RHPI6TTUc+LTvtdZVppq8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Felix Fietkau , Sasha Levin Subject: [PATCH 7.3 1470/2651] wifi: mt76: mt7996: size the MLD setup TLV by the links it describes Date: Wed, 18 Nov 2026 15:45:10 +0100 Message-ID: <20261118150340.954019793@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Felix Fietkau [ Upstream commit 24cc6d911e1d2f6ada086402f07b30b42fe6b545 ] mt7996_mcu_sta_mld_setup_tlv() sets link_num and the TLV length from hweight16(sta->valid_links), but fills an entry only for active links that have driver state. On a station interface mac80211 activates only the association link at first, and drv_change_sta_links() masks the other links with vif->active_links, so the driver has no state for them. A station with valid_links 0x3 and active_links 0x2 thus sends STA_REC_MLD with link_num 2 and a second entry of zeroes, at association and again at authorization. The zeroed entry names WTBL index 0 and BSS index 0 as a link of the MLD. Count the links with driver state first and describe exactly those, with the secondary id taken from them. A link removed without flush keeps its mt7996_sta_link but is no longer valid, so leave it out as well. Fixes: 00cef41d9d8f ("wifi: mt76: mt7996: Add mt7996_mcu_sta_mld_setup_tlv() and mt7996_mcu_sta_eht_mld_tlv()") Link: https://patch.msgid.link/20261006205936.669125-5-nbd@nbd.name Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7996/main.c | 30 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7996/mcu.c | 26 +++++++--------- .../wireless/mediatek/mt76/mt7996/mt7996.h | 2 ++ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index 0ec919dda036e..f8d294b691ba9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -1262,6 +1262,36 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev, } } +u16 mt7996_mac_sta_links(struct mt7996_dev *dev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; + struct ieee80211_link_sta *link_sta; + unsigned int link_id; + u16 links = 0; + + for_each_sta_active_link(vif, sta, link_sta, link_id) { + struct mt7996_sta_link *msta_link; + + msta_link = mt7996_sta_link_protected(dev, msta, link_id); + if (!msta_link) + continue; + + if (sta->valid_links && !msta_link->wcid.link_valid) + continue; + + if (!link_conf_dereference_protected(vif, link_id)) + continue; + + if (!mt7996_vif_link(dev, vif, link_id)) + continue; + + links |= BIT(link_id); + } + + return links; +} + static void mt7996_mac_sta_remove_links(struct mt7996_dev *dev, struct ieee80211_vif *vif, struct ieee80211_sta *sta, unsigned long links, diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c index 310ce18ec12c8..02f9bcfdf5d98 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c @@ -2759,18 +2759,20 @@ mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb, struct ieee80211_sta *sta) { struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; - unsigned int nlinks = hweight16(sta->valid_links); + unsigned long links = mt7996_mac_sta_links(dev, vif, sta); + unsigned int nlinks = hweight16(links); struct mld_setup_link *mld_setup_link; - struct ieee80211_link_sta *link_sta; struct sta_rec_mld_setup *mld_setup; struct mt7996_sta_link *msta_link; + u8 seclink_id = msta->deflink_id; unsigned int link_id; struct tlv *tlv; - msta_link = mt7996_sta_link_protected(dev, msta, msta->deflink_id); - if (!msta_link) + if (!(links & BIT(msta->deflink_id))) return; + msta_link = mt7996_sta_link_protected(dev, msta, msta->deflink_id); + tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MLD, sizeof(struct sta_rec_mld_setup) + sizeof(struct mld_setup_link) * nlinks); @@ -2780,26 +2782,18 @@ mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb, mld_setup->setup_wcid = cpu_to_le16(msta_link->wcid.idx); mld_setup->primary_id = cpu_to_le16(msta_link->wcid.idx); - if (nlinks > 1) { - msta_link = mt7996_sta_link_protected(dev, msta, - msta->seclink_id); - if (!msta_link) - return; - } + if (links & BIT(msta->seclink_id)) + seclink_id = msta->seclink_id; + msta_link = mt7996_sta_link_protected(dev, msta, seclink_id); mld_setup->seconed_id = cpu_to_le16(msta_link->wcid.idx); mld_setup->link_num = nlinks; mld_setup_link = (struct mld_setup_link *)mld_setup->link_info; - for_each_sta_active_link(vif, sta, link_sta, link_id) { + for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) { struct mt7996_vif_link *link; msta_link = mt7996_sta_link_protected(dev, msta, link_id); - if (!msta_link) - continue; - link = mt7996_vif_link(dev, vif, link_id); - if (!link) - continue; mld_setup_link->wcid = cpu_to_le16(msta_link->wcid.idx); mld_setup_link->bss_idx = link->mt76.idx; diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h index dcfdcd5975c3c..82a2a8a5db69e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h @@ -894,6 +894,8 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev, void mt7996_mac_sta_remove_link(struct mt7996_dev *dev, struct ieee80211_sta *sta, unsigned int link_id, bool flush); +u16 mt7996_mac_sta_links(struct mt7996_dev *dev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct ieee80211_twt_setup *twt); -- 2.53.0