Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 16/29] wifi: mt76: mt7996: leave PS when a 4-address connection is established
Date: Fri, 24 Jul 2026 12:48:00 +0000	[thread overview]
Message-ID: <20260724124813.3961474-16-nbd@nbd.name> (raw)
In-Reply-To: <20260724124813.3961474-1-nbd@nbd.name>

From: Peter Chiu <chui-hao.chiu@mediatek.com>

Because 4 address non-AMSDU packets do not have a bssid field, the
hardware cannot get the bssid. Without the bssid, stations are not
able to leave PS mode due to HW design. Wake up non-setup links when
4-address mode is established to prevent this issue.

mt7992 and mt7990 handle this via the BSSID mapping band config
instead, so restrict the command to mt7996.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h   |  1 +
 .../net/wireless/mediatek/mt76/mt7996/main.c   |  8 ++++++++
 .../net/wireless/mediatek/mt76/mt7996/mcu.c    | 18 ++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7996/mcu.h    |  6 ++++++
 .../net/wireless/mediatek/mt76/mt7996/mt7996.h |  2 ++
 5 files changed, 35 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 8198efc6c05d..51380849d24e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -867,6 +867,7 @@ enum {
 	STA_REC_HDRT = 0x28,
 	STA_REC_EML_OP = 0x29,
 	STA_REC_HDR_TRANS = 0x2B,
+	STA_REC_PS_LEAVE = 0x45,
 	STA_REC_MAX_NUM
 };
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 57afe4e81666..b6717d4e4dda 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -2067,6 +2067,14 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw,
 			continue;
 
 		mt7996_mcu_wtbl_update_hdr_trans(dev, vif, link, msta_link);
+
+		/* HW cannot derive the BSSID from 4-address non-AMSDU frames,
+		 * so PS exit is missed on links other than the setup link.
+		 * Let the firmware wake those links instead.
+		 */
+		if (enabled && msta->deflink_id != link_id &&
+		    is_mt7996(&dev->mt76))
+			mt7996_mcu_ps_leave(dev, link, msta_link);
 	}
 
 	mutex_unlock(&dev->mt76.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 69676a605549..57117ce69cbb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -5184,6 +5184,24 @@ int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
 				     MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
 }
 
+int mt7996_mcu_ps_leave(struct mt7996_dev *dev, struct mt7996_vif_link *link,
+			struct mt7996_sta_link *msta_link)
+{
+	struct sk_buff *skb;
+
+	skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &link->mt76,
+					      &msta_link->wcid,
+					      MT7996_STA_UPDATE_MAX_SIZE);
+	if (IS_ERR(skb))
+		return PTR_ERR(skb);
+
+	mt76_connac_mcu_add_tlv(skb, STA_REC_PS_LEAVE,
+				sizeof(struct sta_rec_ps_leave));
+
+	return mt76_mcu_skb_send_msg(&dev->mt76, skb,
+				     MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
+}
+
 int mt7996_mcu_set_fixed_rate_table(struct mt7996_phy *phy, u8 table_idx,
 				    u16 rate_idx, bool beacon)
 {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
index b53a9e71c281..1487d33a8dbb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
@@ -680,6 +680,12 @@ struct sta_rec_hdr_trans {
 	u8 mesh;
 } __packed;
 
+struct sta_rec_ps_leave {
+	__le16 tag;
+	__le16 len;
+	u8 __rsv[4];
+} __packed;
+
 struct sta_rec_mld_setup {
 	__le16 tag;
 	__le16 len;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index dcacc7d06e85..2a0cdb56f822 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -928,6 +928,8 @@ int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
 				     struct ieee80211_vif *vif,
 				     struct mt7996_vif_link *link,
 				     struct mt7996_sta_link *msta_link);
+int mt7996_mcu_ps_leave(struct mt7996_dev *dev, struct mt7996_vif_link *link,
+			struct mt7996_sta_link *msta_link);
 int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode);
 int mt7996_mcu_set_emlsr_mode(struct mt7996_dev *dev,
 			      struct ieee80211_vif *vif,
-- 
2.53.0


  parent reply	other threads:[~2026-07-24 12:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 12:47 [PATCH mt76-next 01/29] wifi: mt76: fix HE DCM max-RU capability encoding Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 02/29] wifi: mt76: mt7996: bound TLV walk in mt7996_mcu_get_chip_config Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 03/29] wifi: mt76: fix out-of-bounds access in mmio copy helpers Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 04/29] wifi: mt76: mt7915: unwind state on add_interface failure Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 05/29] wifi: mt76: mt7996: hold dev->mt76.mutex while disabling tx worker in SER Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 06/29] wifi: mt76: decode the full VHT Rx STBC capability field Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 07/29] wifi: mt76: fix ER-SU 106-tone RU check in RX rate decode Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 08/29] wifi: mt76: mt7996: reserve space for the CSA-abort countdown TLV Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 09/29] wifi: mt76: mt7996: don't leak MLD group index on remap alloc failure Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 10/29] wifi: mt76: cancel reset and rc work on device unregister Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 11/29] wifi: mt76: report data NSS for STBC frames in RX rate decode Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 12/29] wifi: mt76: mt7915: use little-endian for bss_info_ra wire fields Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 13/29] wifi: mt76: mt7996: add missing rdd_idx check when enabling background radar Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 14/29] wifi: mt76: only consume the WO drop bit on WED v2 devices Felix Fietkau
2026-07-24 12:47 ` [PATCH mt76-next 15/29] wifi: mt76: mt7996: add mcu command to set bssid mapping address Felix Fietkau
2026-07-24 12:48 ` Felix Fietkau [this message]
2026-07-24 12:48 ` [PATCH mt76-next 17/29] wifi: mt76: mt7915: unlink TWT flow if the MCU rejects the agreement Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 18/29] wifi: mt76: mt7996: skip key upload when adding an offchannel link Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 19/29] wifi: mt76: mt7996: wake MCU waiters before aborting scan in L1 SER Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 20/29] wifi: mt76: fix queue reg access when building WED and NPU together Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 21/29] wifi: mt76: mt7996: select net_setup_tc handler at runtime Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 22/29] wifi: mt76: fix stuck TX queues after SER with no active interfaces Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 23/29] wifi: mt76: mt7615: fix NULL deref in mt7615_mac_set_rates Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 24/29] mt76: mt7915: trigger L1 SER on PLE MDP RIOC hang Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 25/29] wifi: mt76: mt7996: free vif links after clearing wcid entries on full reset Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 26/29] wifi: mt76: mt7996: clear stale link state " Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 27/29] wifi: mt76: set MT76_SCANNING when starting a hw scan Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 28/29] wifi: mt76: serialize scan-link teardown with dev->mutex Felix Fietkau
2026-07-24 12:48 ` [PATCH mt76-next 29/29] wifi: mt76: mt7996: hold dev->mutex in remove_interface teardown 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=20260724124813.3961474-16-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /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