Linux wireless drivers development
 help / color / mirror / Atom feed
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 26/28] wifi: mt76: mt7925: remap hybrid-MLO TX to the primary link OMAC
Date: Tue, 10 Nov 2026 11:12:42 +0800	[thread overview]
Message-ID: <20261110031244.369014-27-emery.hsin@mediatek.com> (raw)
In-Reply-To: <20261110031244.369014-1-emery.hsin@mediatek.com>

In 3-link hybrid MLO the firmware aggregates all links under the primary
link OMAC. Derive the TX OM-remap index from the current valid_links when
the BSS MLD TLV is built, set it there and in the TXD with OM_MAP (BIT(9)
on MT7925 and MT7928, BIT(8) otherwise). Without hybrid MLO the TXD is
unchanged.

Signed-off-by: Emery Hsin <emery.hsin@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7925/mac.c  | 13 ++++++++++++-
 drivers/net/wireless/mediatek/mt76/mt7925/main.c |  7 +++++++
 drivers/net/wireless/mediatek/mt76/mt7925/mcu.c  | 15 ++++++++++++++-
 drivers/net/wireless/mediatek/mt76/mt792x.h      |  4 ++++
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 20acfcb9d1b9..6668a0c9a28d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -761,6 +761,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 	bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
 					 BSS_CHANGED_FILS_DISCOVERY));
 	struct mt792x_bss_conf *mconf;
+	u32 om_map = 0;
 
 	mconf = vif ? mt792x_vif_to_link((struct mt792x_vif *)vif->drv_priv,
 					 wcid->link_id) : NULL;
@@ -772,6 +773,16 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 		band_idx = mvif->band_idx;
 	}
 
+	/* hybrid MLO: send every link under the primary OMAC via the OM remap
+	 * table
+	 */
+	if (mconf && mconf->om_remap_idx != MT792x_OM_REMAP_IDX_NONE) {
+		omac_idx = mconf->om_remap_idx;
+		/* OM_MAP is BIT(9) on MT7925/MT7928, BIT(8) on other chips */
+		om_map = is_mt7925(dev) || is_mt7928(dev) ?
+			 MT_TXD2_OWN_MAC_MAP_V2 : MT_TXD2_OWN_MAC_MAP;
+	}
+
 	if (inband_disc) {
 		p_fmt = MT_TX_TYPE_FW;
 		q_idx = MT_LMAC_ALTX0;
@@ -804,7 +815,7 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 		val |= FIELD_PREP(MT_TXD1_TGID, band_idx);
 
 	txwi[1] = cpu_to_le32(val);
-	txwi[2] = 0;
+	txwi[2] = cpu_to_le32(om_map);
 
 	val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, 15);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 2b1346044c5a..d272c06df254 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -403,6 +403,11 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
 		mconf->mt76.omac_idx = mvif->bss_conf.mt76.idx;
 	else
 		mconf->mt76.omac_idx = mconf->mt76.idx;
+	/* The hybrid-MLO TX OM remap index is derived per BSS_INFO from the
+	 * current valid_links in mt7925_mcu_bss_mld_tlv(), not here: the deflink
+	 * is added before the MLD exists.
+	 */
+	mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE;
 	mconf->mt76.band_idx = MT792x_BAND_AUTO;
 
 	mconf->absent = false;
@@ -1538,6 +1543,7 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,
 
 		/* reset to auto band so the deactivate drops the band binding */
 		mconf->mt76.band_idx = MT792x_BAND_AUTO;
+		mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE;
 		/* back to the legacy WMM index, MLO uses 0 */
 		mconf->mt76.wmm_idx = mconf->mt76.idx %
 				      MT76_CONNAC_MAX_WMM_SETS;
@@ -1608,6 +1614,7 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
 
 		/* reset to auto band before the disconnect command */
 		mconf->mt76.band_idx = MT792x_BAND_AUTO;
+		mconf->om_remap_idx = MT792x_OM_REMAP_IDX_NONE;
 
 		mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf,
 					link_sta, false);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 2c2ab85180c4..d02242870115 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -3272,10 +3272,14 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
 	struct bss_mld_tlv *mld;
 	struct tlv *tlv;
 	bool is_mld;
+	bool is_hybrid;
 	bool is_supported_ap = false;
 
 	is_mld = ieee80211_vif_is_mld(link_conf->vif) ||
 		 (hweight16(mvif->valid_links) > 1);
+	/* three links means hybrid MLO */
+	is_hybrid = hweight16(mvif->valid_links) >= 3 &&
+		    (phy->chip_cap & BIT(MT792x_CHIP_CAP_MLO_HYBRID_EN));
 
 	tlv = mt76_connac_mcu_add_tlv(skb, UNI_BSS_INFO_MLD, sizeof(*mld));
 	mld = (struct bss_mld_tlv *)tlv;
@@ -3284,7 +3288,16 @@ mt7925_mcu_bss_mld_tlv(struct sk_buff *skb,
 	/* apply the index of the primary link */
 	mld->group_mld_id = is_mld ? mvif->bss_conf.mt76.idx : 0xff;
 	mld->own_mld_id = mconf->mt76.idx + 32;
-	mld->remap_idx = 0xff;
+	/* Hybrid MLO remaps every link's TX OWN_MAC to the primary link OMAC;
+	 * derive it here from the current valid_links so the deflink (added
+	 * before the MLD existed) is covered too, and cache it for the TX path.
+	 */
+	mld->remap_idx = is_hybrid ? mvif->bss_conf.mt76.omac_idx :
+				     MT792x_OM_REMAP_IDX_NONE;
+	mconf->om_remap_idx = mld->remap_idx;
+
+	/* enable hybrid MLO in firmware */
+	mld->hybrid_mode = is_hybrid;
 
 	/* single active link, STR is not supported */
 	mld->max_link_num = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index f1a0a296ae0f..7d5ef7d785a2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -176,6 +176,9 @@ struct mt792x_chanctx {
 	struct mt792x_bss_conf *bss_conf;
 };
 
+/* no OM remap */
+#define MT792x_OM_REMAP_IDX_NONE	0xff
+
 struct mt792x_bss_conf {
 	struct mt76_vif_link mt76; /* must be first */
 	struct mt792x_vif *vif;
@@ -189,6 +192,7 @@ struct mt792x_bss_conf {
 	/* For group-addressed frames that are sent outside a TXQ */
 	struct mt792x_link_sta bmc;
 	bool bmc_valid;
+	u8 om_remap_idx; /* TX OM remap index, 0xff if none */
 };
 
 struct mt792x_nan_conf {
-- 
2.45.2


  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 ` [PATCH 19/28] wifi: mt76: mt7925: publish every link before sending any STA_REC Emery Hsin
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 ` Emery Hsin [this message]
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-27-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