From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A76AE606A32D for ; Wed, 2 Dec 2026 07:52:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=4fe/WW8V; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J5ad86bb DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Cc:To:In-Reply-To:References:Message-Id: Content-Type:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=ZnnTSFzy0+A4LtYEWrzFrrL6/lFRb9VELbxPzQ/lTDw=; b=4fe/WW8VBcNOJj6IA4jF64pEDi Jin1OrtO/5mTV/QHXR6Ko2X1bbOJpduH9heyMnL+0rtAEbManf6qdBi13mQEPkVfysWBZ//UG74hT pNhNTCqJz+9szAprdJEeEQYmJG9YFOEsmtorNXVw7Vt982f2SzxSHhYElYdG3KWxFHYuczL4aKueF N8XBwZcZGKso/FQq0xRpbVJIR1QmfHP0GfrAFOFm75gsXCObLbkW01rPunVuDzOc/Rlrtuqc8iDnh 9dvKYQf0C+4+YkrVYHc8PjrgCAWH95pKgNjT4pZw+2ICFtZ86VjL1IrymQIOVVUkbVPBwZukbT86q ci9x1sLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYf8s-0000000AZZG-1DoR; Wed, 02 Dec 2026 07:52:42 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYf8o-0000000AZWD-10Ra for linux-mediatek@lists.infradead.org; Wed, 02 Dec 2026 07:52:38 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 080E4611BE; Wed, 2 Dec 2026 07:52:37 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796197956; b=XD9pCu9sDUOaGInnx89JyrKcwfbr6sQUvVpwuDOootAi5rOIAVUaNVivBxcShlk8fbTv CxUcMlevoFuNHjWd9iKx0j/Qye2zIbu8lHVZK2tPmZjzNnOcpM9kyspHlWFusftDBI4ID KMIWlM97k1kjVjWKYU8eu5yv0xWutqXGJGyBJOqPXPAo/yZUvQQsh/abLvMT2buLEjs7+ pyAxbaCf6tPpGCaTJJ/ttT55RvfcW+aHcJJSPvFYqUNWaXDy8fMinG16X7oFZcetB8f5z NtpEo5GIjqi8HjajDlwwUupXn8lUlMJ8OO1cZPLK2a9rpNAUIHleukmKOwoe0/dPaLA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796197956; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=ZnnTSFzy0+A4LtYEWrzFrrL6/lFRb9VELbxPzQ/lTDw=; b=vALWso3brMoR1eL2upaMz+7Cly4053l0PEhyobLU+SqbPail3v1Afs/byXZ4ykxdJIVj LY4js7irJOV7R5PzL6xPUeojhrMraamtsnmaQfNBMlMKB4+9I55T7fXzVc+rUnl9l0vvx A6e6j2NnnfhVowwrVVDiBD122KOx9+qsKfIzAF3kQ6GvgMNSWsDNbfD/8hxlpJV8Aw98y I2yOGx+PWWpb8LpsqhQpHNXwisjJycu0dKZvMdSNPp640u4lz+YiZjLgyCx0yjzKLbeKC s/iY0568H4KGY+N2WwZFi9c5b3kYWEl4nZDuQ7nmSUgoCLtUlAGFP59yDi312mrTeGA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 23E521F0092B; Wed, 2 Dec 2026 07:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796197956; bh=ZnnTSFzy0+A4LtYEWrzFrrL6/lFRb9VELbxPzQ/lTDw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=J5ad86bbbFEPquX0u3/W2SReS61VwU0mHCzjPJUAgvMDf62X+EirvaSyO30Z5VXcs A+1Dg17dnhdCssoFipLbbmpSdjR7EamjPi+gQXr/yYm/eEjCP/SX28x3ZUGcQ7PP/H Xh/EdjZE7wD3jtkv40gN0je59eM8WGYiykCmd6tr3qmlarJ0v0uqhr8NDlTB5fZ09N uKUi+UAYMCbvmPCk9dVAdi5pV1/tkcBkyLLxFrW5+BzI/kuo+gC2oxLisirYrqxkGf cixA8bhyppSEUQ4Il5brWzkAdaXc9FpGZrYlWEWQdxRey/eUNWOCZ8d+jBvVu3aFwk kDjq1hcd+a0Mw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 9EA0A4F2EF; Wed, 2 Dec 2026 07:52:35 +0000 (UTC) From: Zichao-xu via B4 Relay Date: Wed, 02 Dec 2026 16:52:36 +0900 Subject: [PATCH RFC 3/3] wifi: mt76: mt7996: wake a link that an MLO peer left with frames queued X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261202-rfc-v1-3-eff86f0bf9e6@gmail.com> References: <20261202-rfc-v1-0-eff86f0bf9e6@gmail.com> In-Reply-To: <20261202-rfc-v1-0-eff86f0bf9e6@gmail.com> To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , linux-mediatek@lists.infradead.org, Zichao-xu X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796197954; l=4539; i=xvzichao2333@gmail.com; s=20261202; h=from:subject:message-id; bh=RwMZ4SEVls7VG19lSjz06TMco9rax7pcoizv1pblfYE=; b=HC3+t8yicaBmrOKnBUU4/A/AdKjogSCAQHMgGE9NzeU8VEry+Ssj0nj/JLnQKOI6Edhm4I4jf AOyFykvwQJGBkRpctC+1pwFXJu7LiqAyXBTmLlSzdWVnbaFlZWhtiG/ X-Developer-Key: i=xvzichao2333@gmail.com; a=ed25519; pk=4y2PCqVVaZTmU/wzky/gd6WColWnjFznkFN8fXd+GMI= X-Endpoint-Received: by B4 Relay for xvzichao2333@gmail.com/20261202 with auth_id=1717 X-Original-From: Zichao-xu Content-Transfer-Encoding: 7bit X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: xvzichao2333@gmail.com Sender: "Linux-mediatek" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, FREEMAIL_REPLYTO_END_DIGIT,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Zichao-xu An MLO peer that moves to another link can leave frames in the LMAC queue of the link it left, and the firmware holds them for as long as it considers the peer dozing there. They count against the non-AQL limit shared by all links of the peer, so the peer stops being served on every link, including the one it is active on. Seen on MT7996 with the previous patch applied: the peer was active on 5 GHz (unicast RX 70 ms before) and all of its TXQs pointed at the 5 GHz wcid, but 36 frames were left in the AC3 PLE queue of its 2.4 GHz wcid (head fid unchanged over 2 s, no RX on 2.4 GHz for 25 s). 37 non-AQL frames were pending, so nothing was sent to the peer on 5 GHz either, and the backlog in mac80211 grew until the station was disconnected. >From mac_work, look for MLO peer links that are in PS while the peer was recently active on another link and at least MT_MAX_NON_AQL_PKT / 2 non-AQL frames are pending, and send STA_REC_PS_LEAVE for such a link, at most once per second per link, so that the firmware sends or drops the frames held there. mt7996_mcu_ps_leave() is already used to work around a missed PS exit of 4-address peers. Signed-off-by: Zichao-xu --- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 63 ++++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 1 + 2 files changed, 64 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c index d046fed..cad6430 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c @@ -3179,6 +3179,68 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) mutex_unlock(&dev->mt76.mutex); } +/* + * An MLO peer that moves to another link can leave frames in the LMAC queue + * of the link it left, and the firmware holds them for as long as it + * considers the peer dozing there. They count against the non-AQL limit + * shared by all links of the peer, so the peer stops being served on every + * link. Ask the firmware to wake the left link, so those frames are sent or + * fail. + */ +static void +mt7996_mac_mlo_ps_leave_check(struct mt7996_phy *phy) +{ + struct mt7996_dev *dev = phy->dev; + int i; + + lockdep_assert_held(&dev->mt76.mutex); + + for (i = 0; i < mt7996_wtbl_size(dev); i++) { + struct mt7996_sta_link *msta_link; + struct mt7996_vif_link *link; + struct ieee80211_sta *sta; + struct mt7996_sta *msta; + struct mt76_wcid *wcid; + u8 link_id, rx_id; + + wcid = mt76_dereference(dev->mt76.wcid[i], &dev->mt76); + if (!wcid || wcid->phy_idx != phy->mt76->band_idx || + !test_bit(MT_WCID_FLAG_PS, &wcid->flags)) + continue; + + sta = wcid_to_sta(wcid); + if (!sta || !sta->mlo) + continue; + + msta_link = container_of(wcid, struct mt7996_sta_link, wcid); + msta = msta_link->sta; + link_id = wcid->link_id; + if (!msta || !msta->vif || + link_id >= IEEE80211_MLD_MAX_NUM_LINKS) + continue; + + rx_id = mt7996_sta_active_link(msta); + if (rx_id == IEEE80211_LINK_UNSPECIFIED || rx_id == link_id) + continue; + + if (atomic_read(&mt76_wcid_primary(wcid)->non_aql_packets) < + MT_MAX_NON_AQL_PKT / 2) + continue; + + if (time_before(jiffies, msta->ps_leave_jiffies[link_id] + HZ)) + continue; + + link = (struct mt7996_vif_link *) + mt76_dereference(msta->vif->mt76.link[link_id], + &dev->mt76); + if (!link) + continue; + + msta->ps_leave_jiffies[link_id] = jiffies; + mt7996_mcu_ps_leave(dev, link, msta_link); + } +} + void mt7996_mac_work(struct work_struct *work) { struct mt7996_phy *phy; @@ -3191,6 +3253,7 @@ void mt7996_mac_work(struct work_struct *work) mutex_lock(&mphy->dev->mutex); mt76_update_survey(mphy); + mt7996_mac_mlo_ps_leave_check(phy); if (++mphy->mac_work_count == 5) { mphy->mac_work_count = 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h index e7d8c3c..48fa58d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h @@ -329,6 +329,7 @@ struct mt7996_sta { /* link and time of the last unicast frame received from the peer */ u8 last_rx_link; unsigned long last_rx_jiffies; + unsigned long ps_leave_jiffies[IEEE80211_MLD_MAX_NUM_LINKS]; u8 conn_state; u16 peer_mld_links; u16 fw_mld_idx; -- Git-157)