Skip to contentSkip to conversation

wifi: mt76: connac: use is_connac2() to replace is_mt7921() checks

PATCH In review [email protected] 2 participants 16 messages Feb 19 – Mar 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/11 wifi: mt76: connac: use is_connac2() to replace is_mt7921() checks

From: Sean Wang <[email protected]>

Unify all per-chip conditionals under the new is_connac2() helper. This avoids confusion caused by the previous is_mt7921() check, which implicitly covered multiple connac2 chipsets and no longer reflected its actual scope. This is a clean-up only change with no functional impact.

---
 .../net/wireless/mediatek/mt76/mt76_connac.h  |  2 +-
 .../wireless/mediatek/mt76/mt76_connac_mac.c  | 16 ++++++------
 .../wireless/mediatek/mt76/mt76_connac_mcu.c  | 26 +++++++++----------
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  2 +-
 .../net/wireless/mediatek/mt76/mt792x_core.c  |  2 +-
 .../net/wireless/mediatek/mt76/mt792x_dma.c   |  2 +-
 6 files changed, 25 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +1 -1
index 813d61bffc2c..02bea67d37c3 100644
@@ -187,7 +187,7 @@ static inline bool is_mt7922(struct mt76_dev *dev)
 	return mt76_chip(dev) == 0x7922;
 }
 
-static inline bool is_mt7921(struct mt76_dev *dev)
+static inline bool is_connac2(struct mt76_dev *dev)
 {
 	return mt76_chip(dev) == 0x7961 || is_mt7922(dev) || is_mt7920(dev);
 }
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +8 -8
index 4ef44514d48d..e76f6e28b7f0 100644
@@ -173,7 +173,7 @@ void mt76_connac_write_hw_txp(struct mt76_dev *dev,
 
 	txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID);
 
-	if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+	if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
 		last_mask = MT_TXD_LEN_LAST;
 	else
 		last_mask = MT_TXD_LEN_AMSDU_LAST |
@@ -217,7 +217,7 @@ mt76_connac_txp_skb_unmap_hw(struct mt76_dev *dev,
 	u32 last_mask;
 	int i;
 
-	if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+	if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
 		last_mask = MT_TXD_LEN_LAST;
 	else
 		last_mask = MT_TXD_LEN_MSDU_LAST;
@@ -309,7 +309,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
 	chandef = mvif->ctx ? &mvif->ctx->def : &mphy->chandef;
 	band = chandef->chan->band;
 
-	if (is_mt7921(mphy->dev)) {
+	if (is_connac2(mphy->dev)) {
 		rateidx = ffs(conf->basic_rates) - 1;
 		goto legacy;
 	}
@@ -547,7 +547,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 	val = MT_TXD1_LONG_FORMAT |
 	      FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
 	      FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
 		val |= MT_TXD1_VTA;
 	if (phy_idx || band_idx)
 		val |= MT_TXD1_TGID;
@@ -556,7 +556,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 	txwi[2] = 0;
 
 	val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, 15);
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
 		val |= MT_TXD3_SW_POWER_MGMT;
 	if (key)
 		val |= MT_TXD3_PROTECT_FRAME;
@@ -598,7 +598,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
 		txwi[6] |= cpu_to_le32(val);
 		txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
 
-		if (!is_mt7921(dev)) {
+		if (!is_connac2(dev)) {
 			u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);
 
 			if (!spe_idx)
@@ -830,7 +830,7 @@ mt76_connac2_mac_decode_he_mu_radiotap(struct mt76_dev *dev, struct sk_buff *skb
 	};
 	struct ieee80211_radiotap_he_mu *he_mu;
 
-	if (is_mt7921(dev)) {
+	if (is_connac2(dev)) {
 		mu_known.flags1 |= HE_BITS(MU_FLAGS1_SIG_B_COMP_KNOWN);
 		mu_known.flags2 |= HE_BITS(MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN);
 	}
@@ -1046,7 +1046,7 @@ int mt76_connac2_mac_fill_rx_rate(struct mt76_dev *dev,
 		stbc = FIELD_GET(MT_PRXV_HT_STBC, v0);
 		gi = FIELD_GET(MT_PRXV_HT_SGI, v0);
 		*mode = FIELD_GET(MT_PRXV_TX_MODE, v0);
-		if (is_mt7921(dev))
+		if (is_connac2(dev))
 			dcm = !!(idx & MT_PRXV_TX_DCM);
 		else
 			dcm = FIELD_GET(MT_PRXV_DCM, v0);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +13 -13
index 3f583e2a1dc1..d7fbf3454bb8 100644
@@ -65,7 +65,7 @@ int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len,
 	int cmd;
 
 	if ((!is_connac_v1(dev) && addr == MCU_PATCH_ADDRESS) ||
-	    (is_mt7921(dev) && addr == 0x900000) ||
+	    (is_connac2(dev) && addr == 0x900000) ||
 	    (is_mt7925(dev) && (addr == 0x900000 || addr == 0xe0002800)) ||
 	    (is_mt799x(dev) && addr == 0x900000))
 		cmd = MCU_CMD(PATCH_START_REQ);
@@ -402,7 +402,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
 	switch (vif->type) {
 	case NL80211_IFTYPE_MESH_POINT:
 	case NL80211_IFTYPE_AP:
-		if (vif->p2p && !is_mt7921(dev))
+		if (vif->p2p && !is_connac2(dev))
 			conn_type = CONNECTION_P2P_GC;
 		else
 			conn_type = CONNECTION_INFRA_STA;
@@ -410,7 +410,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
 		basic->aid = cpu_to_le16(link_sta->sta->aid);
 		break;
 	case NL80211_IFTYPE_STATION:
-		if (vif->p2p && !is_mt7921(dev))
+		if (vif->p2p && !is_connac2(dev))
 			conn_type = CONNECTION_P2P_GO;
 		else
 			conn_type = CONNECTION_INFRA_AP;
@@ -874,7 +874,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
 		struct sta_rec_vht *vht;
 		int len;
 
-		len = is_mt7921(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
+		len = is_connac2(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
 		tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, len);
 		vht = (struct sta_rec_vht *)tlv;
 		vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
@@ -885,7 +885,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
 	/* starec uapsd */
 	mt76_connac_mcu_sta_uapsd(skb, vif, sta);
 
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
 		return;
 
 	if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)
@@ -1778,7 +1778,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
 	req->ssid_type_ext = n_ssids ? BIT(0) : 0;
 	req->ssids_num = n_ssids;
 
-	duration = is_mt7921(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
+	duration = is_connac2(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
 	/* increase channel time for passive scan */
 	if (!sreq->n_ssids)
 		duration *= 2;
@@ -1821,7 +1821,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
 		req->ies_len = cpu_to_le16(sreq->ie_len);
 	}
 
-	if (is_mt7921(phy->dev))
+	if (is_connac2(phy->dev))
 		req->scan_func |= SCAN_FUNC_SPLIT_SCAN;
 
 	memcpy(req->bssid, sreq->bssid, ETH_ALEN);
@@ -1897,7 +1897,7 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy,
 		get_random_mask_addr(addr, sreq->mac_addr,
 				     sreq->mac_addr_mask);
 	}
-	if (is_mt7921(phy->dev)) {
+	if (is_connac2(phy->dev)) {
 		req->mt7921.bss_idx = mvif->idx;
 		req->mt7921.delay = cpu_to_le32(sreq->delay);
 	}
@@ -2037,7 +2037,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
 			  struct mt76_power_limits *limits,
 			  enum nl80211_band band)
 {
-	int max_power = is_mt7921(dev) ? 127 : 63;
+	int max_power = is_connac2(dev) ? 127 : 63;
 	int i, offset = sizeof(limits->cck);
 
 	memset(sku, max_power, MT_SKU_POWER_LIMIT);
@@ -2065,7 +2065,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
 		offset += 12;
 	}
 
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
 		return;
 
 	/* he */
@@ -2121,7 +2121,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
 				  enum nl80211_band band)
 {
 	struct mt76_dev *dev = phy->dev;
-	int sku_len, batch_len = is_mt7921(dev) ? 8 : 16;
+	int sku_len, batch_len = is_connac2(dev) ? 8 : 16;
 	static const u8 chan_list_2ghz[] = {
 		1, 2,  3,  4,  5,  6,  7,
 		8, 9, 10, 11, 12, 13, 14
@@ -2162,7 +2162,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
 	if (!limits)
 		return -ENOMEM;
 
-	sku_len = is_mt7921(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
+	sku_len = is_connac2(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
 	tx_power = 2 * phy->hw->conf.power_level;
 	if (!tx_power)
 		tx_power = 127;
@@ -3080,7 +3080,7 @@ static u32 mt76_connac2_get_data_mode(struct mt76_dev *dev, u32 info)
 {
 	u32 mode = DL_MODE_NEED_RSP;
 
-	if ((!is_mt7921(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
+	if ((!is_connac2(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
 		return mode;
 
 	switch (FIELD_GET(PATCH_SEC_ENC_TYPE_MASK, info)) {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -1
index f44977f9093d..1ef25385f3c6 100644
@@ -1866,7 +1866,7 @@ mt76_connac_mcu_gen_dl_mode(struct mt76_dev *dev, u8 feature_set, bool is_wa)
 
 	ret |= feature_set & FW_FEATURE_SET_ENCRYPT ?
 	       DL_MODE_ENCRYPT | DL_MODE_RESET_SEC_IV : 0;
-	if (is_mt7921(dev) || is_mt7925(dev))
+	if (is_connac2(dev) || is_mt7925(dev))
 		ret |= feature_set & FW_FEATURE_ENCRY_MODE ?
 		       DL_CONFIG_ENCRY_MODE_SEL : 0;
 	ret |= FIELD_PREP(DL_MODE_KEY_IDX,
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -1
index f318a53e4deb..2142fcc4ae27 100644
@@ -151,7 +151,7 @@ void mt792x_stop(struct ieee80211_hw *hw, bool suspend)
 	cancel_work_sync(&dev->reset_work);
 	mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
 
-	if (is_mt7921(&dev->mt76)) {
+	if (is_connac2(&dev->mt76)) {
 		mt792x_mutex_acquire(dev);
 		mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
 		mt792x_mutex_release(dev);
drivers/net/wireless/mediatek/mt76/mt792x_dma.c +1 -1
index 1ddec7788b66..34f07bd3097d 100644
@@ -356,7 +356,7 @@ EXPORT_SYMBOL_GPL(mt792x_poll_rx);
 
 int mt792x_wfsys_reset(struct mt792x_dev *dev)
 {
-	u32 addr = is_mt7921(&dev->mt76) ? 0x18000140 : 0x7c000140;
+	u32 addr = is_connac2(&dev->mt76) ? 0x18000140 : 0x7c000140;
 
 	mt76_clear(dev, addr, WFSYS_SW_RST_B);
 	msleep(50);
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/11 wifi: mt76: mt7921: use mt76_for_each_q_rx() in reset path

From: Sean Wang <[email protected]>

Replace explicit napi_disable() calls for RX queues with mt76_for_each_q_rx() in mt7921e_mac_reset().

This removes hardcoded queue indices and disables all configured RX queues during reset.

---
 drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +3 -3
index 5ec084432ae3..0db7acb3a637 100644
@@ -71,9 +71,9 @@ int mt7921e_mac_reset(struct mt792x_dev *dev)
 	mt76_txq_schedule_all(&dev->mphy);
 
 	mt76_worker_disable(&dev->mt76.tx_worker);
-	napi_disable(&dev->mt76.napi[MT_RXQ_MAIN]);
-	napi_disable(&dev->mt76.napi[MT_RXQ_MCU]);
-	napi_disable(&dev->mt76.napi[MT_RXQ_MCU_WA]);
+	mt76_for_each_q_rx(&dev->mt76, i) {
+		napi_disable(&dev->mt76.napi[i]);
+	}
 	napi_disable(&dev->mt76.tx_napi);
 
 	mt76_connac2_tx_token_put(&dev->mt76);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/11 wifi: mt76: mt7921: handle MT7902 irq_map quirk with mutable copy

In reply to [email protected]

From: Sean Wang <[email protected]>

MT7902 PCIe requires a different wm2_complete_mask value, so introduce a mutable per-device copy of the default irq_map and override the field only for this chip. Other devices continue using the shared const template.

This is a prerequisite patch before enabling MT7902 PCIe support.

---
 drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +14 -0
index 65c7fe671137..5f857a21f362 100644
@@ -327,6 +327,20 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
 	dev->hif_ops = &mt7921_pcie_ops;
 	dev->irq_map = &irq_map;
 	mt76_mmio_init(&dev->mt76, regs);
+
+	if (id->device == 0x7902) {
+		struct mt792x_irq_map *map;
+
+		/* MT7902 needs a mutable copy because wm2_complete_mask differs */
+		map = devm_kmemdup(&pdev->dev, &irq_map,
+				   sizeof(irq_map), GFP_KERNEL);
+		if (!map)
+			return -ENOMEM;
+
+		map->rx.wm2_complete_mask = 0;
+		dev->irq_map = map;
+	}
+
 	tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev);
 
 	dev->phy.dev = dev;
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 03/11] wifi: mt76: mt7921: handle MT7902 irq_map quirk with mutable copy

Hi Sean,

on Linus master tree we still have 'mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);', hence your patch currently won't apply.

Quoted 41 lines · On 2/19/26 01:39, [email protected] wrote:

From: Sean Wang <[email protected]>

MT7902 PCIe requires a different wm2_complete_mask value, so introduce a mutable per-device copy of the default irq_map and override the field only for this chip. Other devices continue using the shared const template.

This is a prerequisite patch before enabling MT7902 PCIe support.

---
  drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +14 -0
index 65c7fe671137..5f857a21f362 100644
@@ -327,6 +327,20 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
  	dev->hif_ops = &mt7921_pcie_ops;
  	dev->irq_map = &irq_map;
  	mt76_mmio_init(&dev->mt76, regs);
+
+	if (id->device == 0x7902) {
+		struct mt792x_irq_map *map;
+
+		/* MT7902 needs a mutable copy because wm2_complete_mask differs */
+		map = devm_kmemdup(&pdev->dev, &irq_map,
+				   sizeof(irq_map), GFP_KERNEL);
+		if (!map)
+			return -ENOMEM;
+
+		map->rx.wm2_complete_mask = 0;
+		dev->irq_map = map;
+	}
+
  	tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev);
 
  	dev->phy.dev = dev;
Signature · 1 line
Best, Philip
author
#4 lore raw

Re: [PATCH 03/11] wifi: mt76: mt7921: handle MT7902 irq_map quirk with mutable copy

Hi Philip,

Quoted 5 lines · Philip Müller

Hi Sean,

on Linus master tree we still have 'mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);', hence your patch currently won't apply.

The patchset is based on the latest mt76 tree.
If needed, please apply the following commit first so the series applies cleanly:
https://github.com/nbd168/wireless/commit/4eefc435c985f4dfdba9afb1c705f0e17377c084
That patch will go to Linus’ master first, then this series.

Quoted 48 lines · On 2/19/26 01:39, [email protected] wrote:
Quoted 31 lines

From: Sean Wang <[email protected]>

MT7902 PCIe requires a different wm2_complete_mask value, so introduce a mutable per-device copy of the default irq_map and override the field only for this chip. Other devices continue using the shared const template.

This is a prerequisite patch before enabling MT7902 PCIe support.

---
  drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +7 -0
index 65c7fe671137..5f857a21f362 100644
@@ -327,6 +327,20 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
      dev->hif_ops = &mt7921_pcie_ops;
      dev->irq_map = &irq_map;
      mt76_mmio_init(&dev->mt76, regs);
+
+     if (id->device == 0x7902) {
+             struct mt792x_irq_map *map;
+
+             /* MT7902 needs a mutable copy because wm2_complete_mask differs */
+             map = devm_kmemdup(&pdev->dev, &irq_map,
+                                sizeof(irq_map), GFP_KERNEL);

drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 346

Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +7 -0
+             if (!map)
+                     return -ENOMEM;
+
+             map->rx.wm2_complete_mask = 0;
+             dev->irq_map = map;
+     }
+
      tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev);
 
      dev->phy.dev = dev;

--
Best, Philip

#5 lore raw

PATCH 4/11 wifi: mt76: mt7921: add MT7902e DMA layout support

In reply to [email protected]

From: Sean Wang <[email protected]>

Add MT7902 PCIe specific DMA layout overrides for MCU TXQ index, RX ring size, and MCU_WA usage. Common layout remains the default for other chips.

This is a prerequisite patch before enabling MT7902 PCIe support.

---
 .../wireless/mediatek/mt76/mt7921/mt7921.h    | 14 +++++++
 .../net/wireless/mediatek/mt76/mt7921/pci.c   | 41 +++++++++++++++----
 2 files changed, 46 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +14 -0
index ad92af98e314..64f60c4fc60c 100644
@@ -17,6 +17,9 @@
 #define MT7921_RX_MCU_RING_SIZE		8
 #define MT7921_RX_MCU_WA_RING_SIZE	512
 
+/* MT7902 Rx Ring0 is for both Rx Event and Tx Done Event */
+#define MT7902_RX_MCU_RING_SIZE		512
+
 #define MT7921_EEPROM_SIZE		3584
 #define MT7921_TOKEN_SIZE		8192
 
@@ -119,6 +122,17 @@ enum mt7921_rxq_id {
 	MT7921_RXQ_MCU_WM = 0,
 };
 
+/* MT7902 assigns its MCU-WM TXQ at index 15 */
+enum mt7902_txq_id {
+	MT7902_TXQ_MCU_WM = 15,
+};
+
+struct mt7921_dma_layout {
+	u8 mcu_wm_txq;
+	u16 mcu_rxdone_ring_size;
+	bool has_mcu_wa;
+};
+
 enum {
 	MT7921_CLC_POWER,
 	MT7921_CLC_CHAN,
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +32 -9

65 lines not on this page · raw message

Signature · 1 line
2.43.0
#6 lore raw

PATCH 5/11 wifi: mt76: connac: mark MT7902 as hw txp devices

In reply to [email protected]

From: Sean Wang <[email protected]>

Add MT7902 to is_mt76_fw_txp() so it follows the legacy TX descriptor path like the other connac2 chips that return false.

This is a prerequisite patch before enabling MT7902 pcie support.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +1 -0
index 02bea67d37c3..d868bb7c7ab8 100644
@@ -271,6 +271,7 @@ static inline bool is_mt76_fw_txp(struct mt76_dev *dev)
 	case 0x7961:
 	case 0x7920:
 	case 0x7922:
+	case 0x7902:
 	case 0x7925:
 	case 0x7663:
 	case 0x7622:
Signature · 1 line
2.43.0
#7 lore raw

PATCH 6/11 wifi: mt76: mt792x: add PSE handling barrier for the large MCU cmd

In reply to [email protected]

From: Sean Wang <[email protected]>

Add a dummy register read in mt76_connac_mcu_rate_txpower_band() to act as a PSE barrier. This would release PSE pages and prevents buffer underflow issues when handling MCU commands with larger payloads without the response in mt76_connac_mcu_set_rate_txpower().

This is a prerequisite patch before enabling MT7902 PCIe and SDIO support.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++++
 drivers/net/wireless/mediatek/mt76/mt792x_regs.h     | 2 ++
 2 files changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +4 -0
index d7fbf3454bb8..89bd52ea8bf7 100644
@@ -4,6 +4,7 @@
 #include <linux/firmware.h>
 #include "mt76_connac2_mac.h"
 #include "mt76_connac_mcu.h"
+#include "mt792x_regs.h"
 
 int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option)
 {
@@ -2246,6 +2247,9 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
 					    false);
 		if (err < 0)
 			goto out;
+
+		/* read a CR to avoid PSE buffer underflow */
+		mt76_connac_mcu_reg_rr(dev, MT_PSE_BASE);
 	}
 
 out:
drivers/net/wireless/mediatek/mt76/mt792x_regs.h +2 -0
index acf627aed609..7ddde9286861 100644
@@ -25,6 +25,8 @@
 #define MT_PLE_AC_QEMPTY(_n)		MT_PLE(0x500 + 0x40 * (_n))
 #define MT_PLE_AMSDU_PACK_MSDU_CNT(n)	MT_PLE(0x10e0 + ((n) << 2))
 
+#define MT_PSE_BASE			0x820c8000
+
 /* TMAC: band 0(0x21000), band 1(0xa1000) */
 #define MT_WF_TMAC_BASE(_band)		((_band) ? 0x820f4000 : 0x820e4000)
 #define MT_WF_TMAC(_band, ofs)		(MT_WF_TMAC_BASE(_band) + (ofs))
Signature · 1 line
2.43.0
#8 lore raw

PATCH 7/11 wifi: mt76: mt792x: ensure MCU ready before ROM patch download

In reply to [email protected]

From: Sean Wang <[email protected]>

Restart the MCU and poll FW state to ensure correct MCU status before downloading the ROM patch.

This is a prerequisite for enabling MT7902 PCIe and has been validated on MT7921 and MT7925 since they share the common code path.

---
 drivers/net/wireless/mediatek/mt76/mt792x_core.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +7 -0
index 2142fcc4ae27..152cfcca2f90 100644
@@ -926,6 +926,13 @@ int mt792x_load_firmware(struct mt792x_dev *dev)
 {
 	int ret;
 
+	mt76_connac_mcu_restart(&dev->mt76);
+
+	if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC_FW_STATE,
+			    MT_TOP_MISC2_FW_PWR_ON, 1000))
+		dev_warn(dev->mt76.dev,
+			 "MCU is not ready for firmware download\n");
+
 	ret = mt76_connac2_load_patch(&dev->mt76, mt792x_patch_name(dev));
 	if (ret)
 		return ret;
Signature · 1 line
2.43.0
#9 lore raw

PATCH 8/11 wifi: mt76: mt7921: add MT7902 MCU support

In reply to [email protected]

From: Sean Wang <[email protected]>

Add MCU support for the MT7902 chipset.

runtime pm is not yet supported by the driver, but normal mac80211 operation is unaffected.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac.h | 8 +++++++-
 drivers/net/wireless/mediatek/mt76/mt7921/init.c | 4 +++-
 drivers/net/wireless/mediatek/mt76/mt792x.h      | 6 ++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +7 -1
index d868bb7c7ab8..51423c7740bd 100644
@@ -182,6 +182,11 @@ static inline bool is_mt7920(struct mt76_dev *dev)
 	return mt76_chip(dev) == 0x7920;
 }
 
+static inline bool is_mt7902(struct mt76_dev *dev)
+{
+	return mt76_chip(dev) == 0x7902;
+}
+
 static inline bool is_mt7922(struct mt76_dev *dev)
 {
 	return mt76_chip(dev) == 0x7922;
@@ -189,7 +194,8 @@ static inline bool is_mt7922(struct mt76_dev *dev)
 
 static inline bool is_connac2(struct mt76_dev *dev)
 {
-	return mt76_chip(dev) == 0x7961 || is_mt7922(dev) || is_mt7920(dev);
+	return mt76_chip(dev) == 0x7961 || is_mt7922(dev) || is_mt7920(dev) ||
+				is_mt7902(dev);
 }
 
 static inline bool is_mt7663(struct mt76_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +3 -1
index 29732315af1c..8e7790702191 100644
@@ -302,7 +302,9 @@ int mt7921_register_device(struct mt792x_dev *dev)
 	dev->pm.idle_timeout = MT792x_PM_TIMEOUT;
 	dev->pm.stats.last_wake_event = jiffies;
 	dev->pm.stats.last_doze_event = jiffies;
-	if (!mt76_is_usb(&dev->mt76)) {
+
+	if (!mt76_is_usb(&dev->mt76) &&
+	    !is_mt7902(&dev->mt76)) {
 		dev->pm.enable_user = true;
 		dev->pm.enable = true;
 		dev->pm.ds_enable_user = true;
drivers/net/wireless/mediatek/mt76/mt792x.h +6 -0
index 8388638ed550..1f381ab356bc 100644
@@ -41,11 +41,13 @@
 #define MT792x_MCU_INIT_RETRY_COUNT	10
 #define MT792x_WFSYS_INIT_RETRY_COUNT	2
 
+#define MT7902_FIRMWARE_WM	"mediatek/WIFI_RAM_CODE_MT7902_1.bin"
 #define MT7920_FIRMWARE_WM	"mediatek/WIFI_RAM_CODE_MT7961_1a.bin"
 #define MT7921_FIRMWARE_WM	"mediatek/WIFI_RAM_CODE_MT7961_1.bin"
 #define MT7922_FIRMWARE_WM	"mediatek/WIFI_RAM_CODE_MT7922_1.bin"
 #define MT7925_FIRMWARE_WM	"mediatek/mt7925/WIFI_RAM_CODE_MT7925_1_1.bin"
 
+#define MT7902_ROM_PATCH	"mediatek/WIFI_MT7902_patch_mcu_1_1_hdr.bin"
 #define MT7920_ROM_PATCH	"mediatek/WIFI_MT7961_patch_mcu_1a_2_hdr.bin"
 #define MT7921_ROM_PATCH	"mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
 #define MT7922_ROM_PATCH	"mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
@@ -448,6 +450,8 @@ void mt792x_config_mac_addr_list(struct mt792x_dev *dev);
 static inline char *mt792x_ram_name(struct mt792x_dev *dev)
 {
 	switch (mt76_chip(&dev->mt76)) {
+	case 0x7902:
+		return MT7902_FIRMWARE_WM;
 	case 0x7920:
 		return MT7920_FIRMWARE_WM;
 	case 0x7922:
@@ -462,6 +466,8 @@ static inline char *mt792x_ram_name(struct mt792x_dev *dev)
 static inline char *mt792x_patch_name(struct mt792x_dev *dev)
 {
 	switch (mt76_chip(&dev->mt76)) {
+	case 0x7902:
+		return MT7902_ROM_PATCH;
 	case 0x7920:
 		return MT7920_ROM_PATCH;
 	case 0x7922:
Signature · 1 line
2.43.0
#10 lore raw

PATCH 9/11 wifi: mt76: mt792x: add MT7902 WFDMA prefetch configuration

In reply to [email protected]

From: Sean Wang <[email protected]>

Configure the RX/TX ring prefetch setting for MT7902 PCIe device.

This is a prerequisite patch before enabling MT7902 PCIe support.

---
 drivers/net/wireless/mediatek/mt76/mt792x_dma.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/wireless/mediatek/mt76/mt792x_dma.c +16 -0
index 34f07bd3097d..002aece857b2 100644
@@ -103,6 +103,22 @@ static void mt792x_dma_prefetch(struct mt792x_dev *dev)
 		mt76_wr(dev, MT_WFDMA0_TX_RING3_EXT_CTRL, PREFETCH(0x0400, 0x10));
 		mt76_wr(dev, MT_WFDMA0_TX_RING15_EXT_CTRL, PREFETCH(0x0500, 0x4));
 		mt76_wr(dev, MT_WFDMA0_TX_RING16_EXT_CTRL, PREFETCH(0x0540, 0x4));
+	} else if (is_mt7902(&dev->mt76)) {
+		/* rx ring */
+		mt76_wr(dev, MT_WFDMA0_RX_RING0_EXT_CTRL, PREFETCH(0x0000, 0x4));
+		mt76_wr(dev, MT_WFDMA0_RX_RING1_EXT_CTRL, PREFETCH(0x0040, 0x4));
+		mt76_wr(dev, MT_WFDMA0_RX_RING2_EXT_CTRL, PREFETCH(0x0080, 0x4));
+		mt76_wr(dev, MT_WFDMA0_RX_RING3_EXT_CTRL, PREFETCH(0x00c0, 0x4));
+		/* tx ring */
+		mt76_wr(dev, MT_WFDMA0_TX_RING0_EXT_CTRL, PREFETCH(0x0100, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING1_EXT_CTRL, PREFETCH(0x0140, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING2_EXT_CTRL, PREFETCH(0x0180, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING3_EXT_CTRL, PREFETCH(0x01c0, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING4_EXT_CTRL, PREFETCH(0x0200, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING5_EXT_CTRL, PREFETCH(0x0240, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING6_EXT_CTRL, PREFETCH(0x0280, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING15_EXT_CTRL, PREFETCH(0x02c0, 0x4));
+		mt76_wr(dev, MT_WFDMA0_TX_RING16_EXT_CTRL, PREFETCH(0x0300, 0x4));
 	} else {
 		/* rx ring */
 		mt76_wr(dev, MT_WFDMA0_RX_RING0_EXT_CTRL, PREFETCH(0x0, 0x4));
Signature · 1 line
2.43.0
#11 lore raw

PATCH 10/11 wifi: mt76: mt7921: add MT7902 PCIe device support

In reply to [email protected]

From: Sean Wang <[email protected]>

Register the MT7902 PCI device ID in the mt7921 driver and add its corresponding firmware and ROM patch names.

---
 drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +4 -0
index 6bb3c6a1cf6a..7a790ddf43bb 100644
@@ -26,6 +26,8 @@ static const struct pci_device_id mt7921_pci_device_table[] = {
 		.driver_data = (kernel_ulong_t)MT7922_FIRMWARE_WM },
 	{ PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7920),
 		.driver_data = (kernel_ulong_t)MT7920_FIRMWARE_WM },
+	{ PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7902),
+		.driver_data = (kernel_ulong_t)MT7902_FIRMWARE_WM },
 	{ },
 };
 
@@ -617,6 +619,8 @@ MODULE_FIRMWARE(MT7921_FIRMWARE_WM);
 MODULE_FIRMWARE(MT7921_ROM_PATCH);
 MODULE_FIRMWARE(MT7922_FIRMWARE_WM);
 MODULE_FIRMWARE(MT7922_ROM_PATCH);
+MODULE_FIRMWARE(MT7902_FIRMWARE_WM);
+MODULE_FIRMWARE(MT7902_ROM_PATCH);
 MODULE_AUTHOR("Sean Wang <[email protected]>");
 MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");
 MODULE_DESCRIPTION("MediaTek MT7921E (PCIe) wireless driver");
Signature · 1 line
2.43.0
#12 lore raw

PATCH 11/11 wifi: mt76: mt7921: add MT7902 SDIO device support

In reply to [email protected]

From: Sean Wang <[email protected]>

Register the MT7902 SDIO device ID in the mt7921 driver and add its corresponding firmware and ROM patch names.

---
 drivers/net/wireless/mediatek/mt76/mt7921/sdio.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/sdio.c +4 -0
index 3421e53dc948..9150f185716c 100644
@@ -19,6 +19,8 @@
 static const struct sdio_device_id mt7921s_table[] = {
 	{ SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, 0x7901),
 		.driver_data = (kernel_ulong_t)MT7921_FIRMWARE_WM },
+	{ SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, 0x7902),
+		.driver_data = (kernel_ulong_t)MT7902_FIRMWARE_WM },
 	{ }	/* Terminating entry */
 };
 
@@ -317,6 +319,8 @@ static int mt7921s_resume(struct device *__dev)
 MODULE_DEVICE_TABLE(sdio, mt7921s_table);
 MODULE_FIRMWARE(MT7921_FIRMWARE_WM);
 MODULE_FIRMWARE(MT7921_ROM_PATCH);
+MODULE_FIRMWARE(MT7902_FIRMWARE_WM);
+MODULE_FIRMWARE(MT7902_ROM_PATCH);
 
 static DEFINE_SIMPLE_DEV_PM_OPS(mt7921s_pm_ops, mt7921s_suspend, mt7921s_resume);
 
Signature · 1 line
2.43.0
#13 lore raw
In reply to [email protected]

Hi Sean,

this patch needed the following lines additionally to compile cleanly:

drivers/net/wireless/mediatek/mt76/mt792x_core.c

@@ -691,7 +691,7 @@ int mt792x_init_wiphy(struct ieee80211_h ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID); ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID);

-    if (is_mt7921(&dev->mt76)) {
+    if (is_connac2(&dev->mt76)) {
         ieee80211_hw_set(hw, CHANCTX_STA_CSA);
     }

Quoted 266 lines · On 2/19/26 01:39, [email protected] wrote:

From: Sean Wang <[email protected]>

Unify all per-chip conditionals under the new is_connac2() helper. This avoids confusion caused by the previous is_mt7921() check, which implicitly covered multiple connac2 chipsets and no longer reflected its actual scope. This is a clean-up only change with no functional impact.

---
  .../net/wireless/mediatek/mt76/mt76_connac.h  |  2 +-
  .../wireless/mediatek/mt76/mt76_connac_mac.c  | 16 ++++++------
  .../wireless/mediatek/mt76/mt76_connac_mcu.c  | 26 +++++++++----------
  .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  2 +-
  .../net/wireless/mediatek/mt76/mt792x_core.c  |  2 +-
  .../net/wireless/mediatek/mt76/mt792x_dma.c   |  2 +-
  6 files changed, 25 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +1 -1
index 813d61bffc2c..02bea67d37c3 100644
@@ -187,7 +187,7 @@ static inline bool is_mt7922(struct mt76_dev *dev)
  	return mt76_chip(dev) == 0x7922;
  }
 
-static inline bool is_mt7921(struct mt76_dev *dev)
+static inline bool is_connac2(struct mt76_dev *dev)
  {
  	return mt76_chip(dev) == 0x7961 || is_mt7922(dev) || is_mt7920(dev);
  }
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +8 -8
index 4ef44514d48d..e76f6e28b7f0 100644
@@ -173,7 +173,7 @@ void mt76_connac_write_hw_txp(struct mt76_dev *dev,
 
  	txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID);
 
-	if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+	if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
  		last_mask = MT_TXD_LEN_LAST;
  	else
  		last_mask = MT_TXD_LEN_AMSDU_LAST |
@@ -217,7 +217,7 @@ mt76_connac_txp_skb_unmap_hw(struct mt76_dev *dev,
  	u32 last_mask;
  	int i;
 
-	if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+	if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
  		last_mask = MT_TXD_LEN_LAST;
  	else
  		last_mask = MT_TXD_LEN_MSDU_LAST;
@@ -309,7 +309,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
  	chandef = mvif->ctx ? &mvif->ctx->def : &mphy->chandef;
  	band = chandef->chan->band;
 
-	if (is_mt7921(mphy->dev)) {
+	if (is_connac2(mphy->dev)) {
  		rateidx = ffs(conf->basic_rates) - 1;
  		goto legacy;
  	}
@@ -547,7 +547,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
  	val = MT_TXD1_LONG_FORMAT |
  	      FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
  	      FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
  		val |= MT_TXD1_VTA;
  	if (phy_idx || band_idx)
  		val |= MT_TXD1_TGID;
@@ -556,7 +556,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
  	txwi[2] = 0;
 
  	val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, 15);
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
  		val |= MT_TXD3_SW_POWER_MGMT;
  	if (key)
  		val |= MT_TXD3_PROTECT_FRAME;
@@ -598,7 +598,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
  		txwi[6] |= cpu_to_le32(val);
  		txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
 
-		if (!is_mt7921(dev)) {
+		if (!is_connac2(dev)) {
  			u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);
 
  			if (!spe_idx)
@@ -830,7 +830,7 @@ mt76_connac2_mac_decode_he_mu_radiotap(struct mt76_dev *dev, struct sk_buff *skb
  	};
  	struct ieee80211_radiotap_he_mu *he_mu;
 
-	if (is_mt7921(dev)) {
+	if (is_connac2(dev)) {
  		mu_known.flags1 |= HE_BITS(MU_FLAGS1_SIG_B_COMP_KNOWN);
  		mu_known.flags2 |= HE_BITS(MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN);
  	}
@@ -1046,7 +1046,7 @@ int mt76_connac2_mac_fill_rx_rate(struct mt76_dev *dev,
  		stbc = FIELD_GET(MT_PRXV_HT_STBC, v0);
  		gi = FIELD_GET(MT_PRXV_HT_SGI, v0);
  		*mode = FIELD_GET(MT_PRXV_TX_MODE, v0);
-		if (is_mt7921(dev))
+		if (is_connac2(dev))
  			dcm = !!(idx & MT_PRXV_TX_DCM);
  		else
  			dcm = FIELD_GET(MT_PRXV_DCM, v0);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +13 -13
index 3f583e2a1dc1..d7fbf3454bb8 100644
@@ -65,7 +65,7 @@ int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len,
  	int cmd;
 
  	if ((!is_connac_v1(dev) && addr == MCU_PATCH_ADDRESS) ||
-	    (is_mt7921(dev) && addr == 0x900000) ||
+	    (is_connac2(dev) && addr == 0x900000) ||
  	    (is_mt7925(dev) && (addr == 0x900000 || addr == 0xe0002800)) ||
  	    (is_mt799x(dev) && addr == 0x900000))
  		cmd = MCU_CMD(PATCH_START_REQ);
@@ -402,7 +402,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
  	switch (vif->type) {
  	case NL80211_IFTYPE_MESH_POINT:
  	case NL80211_IFTYPE_AP:
-		if (vif->p2p && !is_mt7921(dev))
+		if (vif->p2p && !is_connac2(dev))
  			conn_type = CONNECTION_P2P_GC;
  		else
  			conn_type = CONNECTION_INFRA_STA;
@@ -410,7 +410,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
  		basic->aid = cpu_to_le16(link_sta->sta->aid);
  		break;
  	case NL80211_IFTYPE_STATION:
-		if (vif->p2p && !is_mt7921(dev))
+		if (vif->p2p && !is_connac2(dev))
  			conn_type = CONNECTION_P2P_GO;
  		else
  			conn_type = CONNECTION_INFRA_AP;
@@ -874,7 +874,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
  		struct sta_rec_vht *vht;
  		int len;
 
-		len = is_mt7921(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
+		len = is_connac2(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
  		tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, len);
  		vht = (struct sta_rec_vht *)tlv;
  		vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
@@ -885,7 +885,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
  	/* starec uapsd */
  	mt76_connac_mcu_sta_uapsd(skb, vif, sta);
 
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
  		return;
 
  	if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)
@@ -1778,7 +1778,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
  	req->ssid_type_ext = n_ssids ? BIT(0) : 0;
  	req->ssids_num = n_ssids;
 
-	duration = is_mt7921(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
+	duration = is_connac2(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
  	/* increase channel time for passive scan */
  	if (!sreq->n_ssids)
  		duration *= 2;
@@ -1821,7 +1821,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
  		req->ies_len = cpu_to_le16(sreq->ie_len);
  	}
 
-	if (is_mt7921(phy->dev))
+	if (is_connac2(phy->dev))
  		req->scan_func |= SCAN_FUNC_SPLIT_SCAN;
 
  	memcpy(req->bssid, sreq->bssid, ETH_ALEN);
@@ -1897,7 +1897,7 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy,
  		get_random_mask_addr(addr, sreq->mac_addr,
  				     sreq->mac_addr_mask);
  	}
-	if (is_mt7921(phy->dev)) {
+	if (is_connac2(phy->dev)) {
  		req->mt7921.bss_idx = mvif->idx;
  		req->mt7921.delay = cpu_to_le32(sreq->delay);
  	}
@@ -2037,7 +2037,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
  			  struct mt76_power_limits *limits,
  			  enum nl80211_band band)
  {
-	int max_power = is_mt7921(dev) ? 127 : 63;
+	int max_power = is_connac2(dev) ? 127 : 63;
  	int i, offset = sizeof(limits->cck);
 
  	memset(sku, max_power, MT_SKU_POWER_LIMIT);
@@ -2065,7 +2065,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
  		offset += 12;
  	}
 
-	if (!is_mt7921(dev))
+	if (!is_connac2(dev))
  		return;
 
  	/* he */
@@ -2121,7 +2121,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
  				  enum nl80211_band band)
  {
  	struct mt76_dev *dev = phy->dev;
-	int sku_len, batch_len = is_mt7921(dev) ? 8 : 16;
+	int sku_len, batch_len = is_connac2(dev) ? 8 : 16;
  	static const u8 chan_list_2ghz[] = {
  		1, 2,  3,  4,  5,  6,  7,
  		8, 9, 10, 11, 12, 13, 14
@@ -2162,7 +2162,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
  	if (!limits)
  		return -ENOMEM;
 
-	sku_len = is_mt7921(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
+	sku_len = is_connac2(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
  	tx_power = 2 * phy->hw->conf.power_level;
  	if (!tx_power)
  		tx_power = 127;
@@ -3080,7 +3080,7 @@ static u32 mt76_connac2_get_data_mode(struct mt76_dev *dev, u32 info)
  {
  	u32 mode = DL_MODE_NEED_RSP;
 
-	if ((!is_mt7921(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
+	if ((!is_connac2(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
  		return mode;
 
  	switch (FIELD_GET(PATCH_SEC_ENC_TYPE_MASK, info)) {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -1
index f44977f9093d..1ef25385f3c6 100644
@@ -1866,7 +1866,7 @@ mt76_connac_mcu_gen_dl_mode(struct mt76_dev *dev, u8 feature_set, bool is_wa)
 
  	ret |= feature_set & FW_FEATURE_SET_ENCRYPT ?
  	       DL_MODE_ENCRYPT | DL_MODE_RESET_SEC_IV : 0;
-	if (is_mt7921(dev) || is_mt7925(dev))
+	if (is_connac2(dev) || is_mt7925(dev))
  		ret |= feature_set & FW_FEATURE_ENCRY_MODE ?
  		       DL_CONFIG_ENCRY_MODE_SEL : 0;
  	ret |= FIELD_PREP(DL_MODE_KEY_IDX,
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -1
index f318a53e4deb..2142fcc4ae27 100644
@@ -151,7 +151,7 @@ void mt792x_stop(struct ieee80211_hw *hw, bool suspend)
  	cancel_work_sync(&dev->reset_work);
  	mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
 
-	if (is_mt7921(&dev->mt76)) {
+	if (is_connac2(&dev->mt76)) {
  		mt792x_mutex_acquire(dev);
  		mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
  		mt792x_mutex_release(dev);
drivers/net/wireless/mediatek/mt76/mt792x_dma.c +1 -1
index 1ddec7788b66..34f07bd3097d 100644
@@ -356,7 +356,7 @@ EXPORT_SYMBOL_GPL(mt792x_poll_rx);
 
  int mt792x_wfsys_reset(struct mt792x_dev *dev)
  {
-	u32 addr = is_mt7921(&dev->mt76) ? 0x18000140 : 0x7c000140;
+	u32 addr = is_connac2(&dev->mt76) ? 0x18000140 : 0x7c000140;
 
  	mt76_clear(dev, addr, WFSYS_SW_RST_B);
  	msleep(50);
Signature · 1 line
Best, Philip
author
#14 lore raw
Quoted 5 lines · Philip Müller

Hi Sean,

this patch needed the following lines additionally to compile cleanly:

Hi Philip,

Thanks for the catch I’ll update this in the next version.

Best,
Sean

Quoted 283 lines

drivers/net/wireless/mediatek/mt76/mt792x_core.c

(quoted diff) +1 -1
@@ -691,7 +691,7 @@ int mt792x_init_wiphy(struct ieee80211_h
      ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
      ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID);
 
-    if (is_mt7921(&dev->mt76)) {
+    if (is_connac2(&dev->mt76)) {
          ieee80211_hw_set(hw, CHANCTX_STA_CSA);
      }
 
Quoted 258 lines · On 2/19/26 01:39, [email protected] wrote:

From: Sean Wang <[email protected]>

Unify all per-chip conditionals under the new is_connac2() helper. This avoids confusion caused by the previous is_mt7921() check, which implicitly covered multiple connac2 chipsets and no longer reflected its actual scope. This is a clean-up only change with no functional impact.

---
  .../net/wireless/mediatek/mt76/mt76_connac.h  |  2 +-
  .../wireless/mediatek/mt76/mt76_connac_mac.c  | 16 ++++++------
  .../wireless/mediatek/mt76/mt76_connac_mcu.c  | 26 +++++++++----------
  .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  2 +-
  .../net/wireless/mediatek/mt76/mt792x_core.c  |  2 +-
  .../net/wireless/mediatek/mt76/mt792x_dma.c   |  2 +-
  6 files changed, 25 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +1 -1
index 813d61bffc2c..02bea67d37c3 100644
@@ -187,7 +187,7 @@ static inline bool is_mt7922(struct mt76_dev *dev)
      return mt76_chip(dev) == 0x7922;
  }
 
-static inline bool is_mt7921(struct mt76_dev *dev)
+static inline bool is_connac2(struct mt76_dev *dev)
  {
      return mt76_chip(dev) == 0x7961 || is_mt7922(dev) || is_mt7920(dev);
  }
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +8 -8
index 4ef44514d48d..e76f6e28b7f0 100644
@@ -173,7 +173,7 @@ void mt76_connac_write_hw_txp(struct mt76_dev *dev,
 
      txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID);
 
-     if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+     if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
              last_mask = MT_TXD_LEN_LAST;
      else
              last_mask = MT_TXD_LEN_AMSDU_LAST |
@@ -217,7 +217,7 @@ mt76_connac_txp_skb_unmap_hw(struct mt76_dev *dev,
      u32 last_mask;
      int i;
 
-     if (is_mt7663(dev) || is_mt7921(dev) || is_mt7925(dev))
+     if (is_mt7663(dev) || is_connac2(dev) || is_mt7925(dev))
              last_mask = MT_TXD_LEN_LAST;
      else
              last_mask = MT_TXD_LEN_MSDU_LAST;
@@ -309,7 +309,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
      chandef = mvif->ctx ? &mvif->ctx->def : &mphy->chandef;
      band = chandef->chan->band;
 
-     if (is_mt7921(mphy->dev)) {
+     if (is_connac2(mphy->dev)) {
              rateidx = ffs(conf->basic_rates) - 1;
              goto legacy;
      }
@@ -547,7 +547,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
      val = MT_TXD1_LONG_FORMAT |
            FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
            FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
-     if (!is_mt7921(dev))
+     if (!is_connac2(dev))
              val |= MT_TXD1_VTA;
      if (phy_idx || band_idx)
              val |= MT_TXD1_TGID;
@@ -556,7 +556,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
      txwi[2] = 0;
 
      val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, 15);
-     if (!is_mt7921(dev))
+     if (!is_connac2(dev))
              val |= MT_TXD3_SW_POWER_MGMT;
      if (key)
              val |= MT_TXD3_PROTECT_FRAME;
@@ -598,7 +598,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
              txwi[6] |= cpu_to_le32(val);
              txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
 
-             if (!is_mt7921(dev)) {
+             if (!is_connac2(dev)) {
                      u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);
 
                      if (!spe_idx)
@@ -830,7 +830,7 @@ mt76_connac2_mac_decode_he_mu_radiotap(struct mt76_dev *dev, struct sk_buff *skb
      };
      struct ieee80211_radiotap_he_mu *he_mu;
 
-     if (is_mt7921(dev)) {
+     if (is_connac2(dev)) {
              mu_known.flags1 |= HE_BITS(MU_FLAGS1_SIG_B_COMP_KNOWN);
              mu_known.flags2 |= HE_BITS(MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN);
      }
@@ -1046,7 +1046,7 @@ int mt76_connac2_mac_fill_rx_rate(struct mt76_dev *dev,
              stbc = FIELD_GET(MT_PRXV_HT_STBC, v0);
              gi = FIELD_GET(MT_PRXV_HT_SGI, v0);
              *mode = FIELD_GET(MT_PRXV_TX_MODE, v0);
-             if (is_mt7921(dev))
+             if (is_connac2(dev))
                      dcm = !!(idx & MT_PRXV_TX_DCM);
              else
                      dcm = FIELD_GET(MT_PRXV_DCM, v0);
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +13 -13
index 3f583e2a1dc1..d7fbf3454bb8 100644
@@ -65,7 +65,7 @@ int mt76_connac_mcu_init_download(struct mt76_dev *dev, u32 addr, u32 len,
      int cmd;
 
      if ((!is_connac_v1(dev) && addr == MCU_PATCH_ADDRESS) ||
-         (is_mt7921(dev) && addr == 0x900000) ||
+         (is_connac2(dev) && addr == 0x900000) ||
          (is_mt7925(dev) && (addr == 0x900000 || addr == 0xe0002800)) ||
          (is_mt799x(dev) && addr == 0x900000))
              cmd = MCU_CMD(PATCH_START_REQ);
@@ -402,7 +402,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
      switch (vif->type) {
      case NL80211_IFTYPE_MESH_POINT:
      case NL80211_IFTYPE_AP:
-             if (vif->p2p && !is_mt7921(dev))
+             if (vif->p2p && !is_connac2(dev))
                      conn_type = CONNECTION_P2P_GC;
              else
                      conn_type = CONNECTION_INFRA_STA;
@@ -410,7 +410,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
              basic->aid = cpu_to_le16(link_sta->sta->aid);
              break;
      case NL80211_IFTYPE_STATION:
-             if (vif->p2p && !is_mt7921(dev))
+             if (vif->p2p && !is_connac2(dev))
                      conn_type = CONNECTION_P2P_GO;
              else
                      conn_type = CONNECTION_INFRA_AP;
@@ -874,7 +874,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
              struct sta_rec_vht *vht;
              int len;
 
-             len = is_mt7921(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
+             len = is_connac2(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
              tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, len);
              vht = (struct sta_rec_vht *)tlv;
              vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
@@ -885,7 +885,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
      /* starec uapsd */
      mt76_connac_mcu_sta_uapsd(skb, vif, sta);
 
-     if (!is_mt7921(dev))
+     if (!is_connac2(dev))
              return;
 
      if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)
@@ -1778,7 +1778,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
      req->ssid_type_ext = n_ssids ? BIT(0) : 0;
      req->ssids_num = n_ssids;
 
-     duration = is_mt7921(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
+     duration = is_connac2(phy->dev) ? 0 : MT76_CONNAC_SCAN_CHANNEL_TIME;
      /* increase channel time for passive scan */
      if (!sreq->n_ssids)
              duration *= 2;
@@ -1821,7 +1821,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
              req->ies_len = cpu_to_le16(sreq->ie_len);
      }
 
-     if (is_mt7921(phy->dev))
+     if (is_connac2(phy->dev))
              req->scan_func |= SCAN_FUNC_SPLIT_SCAN;
 
      memcpy(req->bssid, sreq->bssid, ETH_ALEN);
@@ -1897,7 +1897,7 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy,
              get_random_mask_addr(addr, sreq->mac_addr,
                                   sreq->mac_addr_mask);
      }
-     if (is_mt7921(phy->dev)) {
+     if (is_connac2(phy->dev)) {
              req->mt7921.bss_idx = mvif->idx;
              req->mt7921.delay = cpu_to_le32(sreq->delay);
      }
@@ -2037,7 +2037,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
                        struct mt76_power_limits *limits,
                        enum nl80211_band band)
  {
-     int max_power = is_mt7921(dev) ? 127 : 63;
+     int max_power = is_connac2(dev) ? 127 : 63;
      int i, offset = sizeof(limits->cck);
 
      memset(sku, max_power, MT_SKU_POWER_LIMIT);
@@ -2065,7 +2065,7 @@ mt76_connac_mcu_build_sku(struct mt76_dev *dev, s8 *sku,
              offset += 12;
      }
 
-     if (!is_mt7921(dev))
+     if (!is_connac2(dev))
              return;
 
      /* he */
@@ -2121,7 +2121,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
                                enum nl80211_band band)
  {
      struct mt76_dev *dev = phy->dev;
-     int sku_len, batch_len = is_mt7921(dev) ? 8 : 16;
+     int sku_len, batch_len = is_connac2(dev) ? 8 : 16;
      static const u8 chan_list_2ghz[] = {
              1, 2,  3,  4,  5,  6,  7,
              8, 9, 10, 11, 12, 13, 14
@@ -2162,7 +2162,7 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
      if (!limits)
              return -ENOMEM;
 
-     sku_len = is_mt7921(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
+     sku_len = is_connac2(dev) ? sizeof(sku_tlbv) : sizeof(sku_tlbv) - 92;
      tx_power = 2 * phy->hw->conf.power_level;
      if (!tx_power)
              tx_power = 127;
@@ -3080,7 +3080,7 @@ static u32 mt76_connac2_get_data_mode(struct mt76_dev *dev, u32 info)
  {
      u32 mode = DL_MODE_NEED_RSP;
 
-     if ((!is_mt7921(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
+     if ((!is_connac2(dev) && !is_mt7925(dev)) || info == PATCH_SEC_NOT_SUPPORT)
              return mode;
 
      switch (FIELD_GET(PATCH_SEC_ENC_TYPE_MASK, info)) {
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -1
index f44977f9093d..1ef25385f3c6 100644
@@ -1866,7 +1866,7 @@ mt76_connac_mcu_gen_dl_mode(struct mt76_dev *dev, u8 feature_set, bool is_wa)
 
      ret |= feature_set & FW_FEATURE_SET_ENCRYPT ?
             DL_MODE_ENCRYPT | DL_MODE_RESET_SEC_IV : 0;
-     if (is_mt7921(dev) || is_mt7925(dev))
+     if (is_connac2(dev) || is_mt7925(dev))
              ret |= feature_set & FW_FEATURE_ENCRY_MODE ?
                     DL_CONFIG_ENCRY_MODE_SEL : 0;
      ret |= FIELD_PREP(DL_MODE_KEY_IDX,
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -1
index f318a53e4deb..2142fcc4ae27 100644
@@ -151,7 +151,7 @@ void mt792x_stop(struct ieee80211_hw *hw, bool suspend)
      cancel_work_sync(&dev->reset_work);
      mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
 
-     if (is_mt7921(&dev->mt76)) {
+     if (is_connac2(&dev->mt76)) {
              mt792x_mutex_acquire(dev);
              mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
              mt792x_mutex_release(dev);
drivers/net/wireless/mediatek/mt76/mt792x_dma.c +0 -0
index 1ddec7788b66..34f07bd3097d 100644

drivers/net/wireless/mediatek/mt76/mt792x_dma.c EXPORT_SYMBOL_GPL(mt792x_poll_rx); · line 362

Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt792x_dma.c +1 -1
@@ -356,7 +356,7 @@ EXPORT_SYMBOL_GPL(mt792x_poll_rx);
 
  int mt792x_wfsys_reset(struct mt792x_dev *dev)
  {
-     u32 addr = is_mt7921(&dev->mt76) ? 0x18000140 : 0x7c000140;
+     u32 addr = is_connac2(&dev->mt76) ? 0x18000140 : 0x7c000140;
 
      mt76_clear(dev, addr, WFSYS_SW_RST_B);
      msleep(50);

--
Best, Philip

#15 lore raw
Quoted 1 line · Sean Wang

Thanks for the catch I’ll update this in the next version.

Hi Sean, thx. Do you have already an updated version of this driver and a rough idea when all of this might reach wireless-next branch?

Signature · 1 line
Best, Philip