Linux wireless drivers development
 help / color / mirror / Atom feed
From: Zichao-xu via B4 Relay <devnull+xvzichao2333.gmail.com@kernel.org>
To: linux-wireless@vger.kernel.org
Cc: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	 Ryder Lee <ryder.lee@mediatek.com>,
	Shayne Chen <shayne.chen@mediatek.com>,
	 Sean Wang <sean.wang@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	 Zichao-xu <xvzichao2333@gmail.com>
Subject: [PATCH RFC 3/3] wifi: mt76: mt7996: wake a link that an MLO peer left with frames queued
Date: Wed, 02 Dec 2026 16:52:36 +0900	[thread overview]
Message-ID: <20261202-rfc-v1-3-eff86f0bf9e6@gmail.com> (raw)
In-Reply-To: <20261202-rfc-v1-0-eff86f0bf9e6@gmail.com>

From: Zichao-xu <xvzichao2333@gmail.com>

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 <xvzichao2333@gmail.com>
---
 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)



  parent reply	other threads:[~2026-12-02  7:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:52 [PATCH RFC 0/3] wifi: mt76: mt7996: fix TX stalls of MLO clients that switch links Zichao-xu via B4 Relay
2026-12-02  7:52 ` [PATCH RFC 1/3] wifi: mt76: limit non-AQL frames queued for a sleeping station Zichao-xu via B4 Relay
2026-12-02  7:52 ` [PATCH RFC 2/3] wifi: mt76: mt7996: steer MLO data frames to the link the peer is active on Zichao-xu via B4 Relay
2026-12-02  7:52 ` Zichao-xu via B4 Relay [this message]
2026-12-02  7:58 ` [PATCH RFC 0/3] wifi: mt76: mt7996: fix TX stalls of MLO clients that switch links Zichao-xu

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=20261202-rfc-v1-3-eff86f0bf9e6@gmail.com \
    --to=devnull+xvzichao2333.gmail.com@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    --cc=xvzichao2333@gmail.com \
    /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