[][MAC80211][misc][Add MT7996 external openwrt build]

[Description]
Add MT7996 external openwrt build

[Release-log]
N/A

Change-Id: I92f3abce893f401df64f7390f1783d4557963848
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6967021
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-wifi-mt76-mt7996-fix-chainmask-calculation-in-mt7996.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-wifi-mt76-mt7996-fix-chainmask-calculation-in-mt7996.patch
new file mode 100644
index 0000000..dfc04e5
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-wifi-mt76-mt7996-fix-chainmask-calculation-in-mt7996.patch
@@ -0,0 +1,34 @@
+From 36dcb418d47fb74f7a5a6fb276ff2fee63f4533a Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Wed, 30 Nov 2022 23:18:03 +0800
+Subject: [PATCH 1/7] wifi: mt76: mt7996: fix chainmask calculation in
+ mt7996_set_antenna()
+
+Fix per-band chainmask when restoring from the dev chainmask.
+
+Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+Change-Id: Idf607cfdfb342fd283d2911231262f0f74994360
+---
+ mt7996/main.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/mt7996/main.c b/mt7996/main.c
+index 4421cd5..c423b05 100644
+--- a/mt7996/main.c
++++ b/mt7996/main.c
+@@ -880,7 +880,10 @@ mt7996_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
+ 	phy->mt76->antenna_mask = tx_ant;
+ 
+ 	/* restore to the origin chainmask which might have auxiliary path */
+-	if (hweight8(tx_ant) == max_nss)
++	if (hweight8(tx_ant) == max_nss && band_idx < MT_BAND2)
++		phy->mt76->chainmask = ((dev->chainmask >> shift) &
++					(BIT(dev->chainshift[band_idx + 1] - shift) - 1)) << shift;
++	else if (hweight8(tx_ant) == max_nss)
+ 		phy->mt76->chainmask = (dev->chainmask >> shift) << shift;
+ 	else
+ 		phy->mt76->chainmask = tx_ant << shift;
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0002-wifi-mt76-mt7996-update-register-for-CFEND_RATE.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0002-wifi-mt76-mt7996-update-register-for-CFEND_RATE.patch
new file mode 100644
index 0000000..927bbe6
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0002-wifi-mt76-mt7996-update-register-for-CFEND_RATE.patch
@@ -0,0 +1,85 @@
+From 6098317d391c07b301bede6002c03ea0eed72103 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Thu, 1 Dec 2022 14:23:35 +0800
+Subject: [PATCH 2/7] wifi: mt76: mt7996: update register for CFEND_RATE
+
+In newer chipsets, CFEND_RATE setting has been moved to different hw
+module.
+
+Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+Change-Id: I41dd443010ede910d934f38f4d86aaa3e7f31032
+---
+ mt7996/mac.c  |  2 +-
+ mt7996/mmio.c |  1 +
+ mt7996/regs.h | 15 ++++++++-------
+ 3 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/mt7996/mac.c b/mt7996/mac.c
+index 0b3e287..ce4242f 100644
+--- a/mt7996/mac.c
++++ b/mt7996/mac.c
+@@ -1690,7 +1690,7 @@ void mt7996_mac_set_timing(struct mt7996_phy *phy)
+ 	else
+ 		val = MT7996_CFEND_RATE_11B;
+ 
+-	mt76_rmw_field(dev, MT_AGG_ACR0(band_idx), MT_AGG_ACR_CFEND_RATE, val);
++	mt76_rmw_field(dev, MT_RATE_HRCR0(band_idx), MT_RATE_HRCR0_CFEND_RATE, val);
+ 	mt76_clear(dev, MT_ARB_SCR(band_idx),
+ 		   MT_ARB_SCR_TX_DISABLE | MT_ARB_SCR_RX_DISABLE);
+ }
+diff --git a/mt7996/mmio.c b/mt7996/mmio.c
+index 60781d0..d8a2c1a 100644
+--- a/mt7996/mmio.c
++++ b/mt7996/mmio.c
+@@ -21,6 +21,7 @@ static const struct __base mt7996_reg_base[] = {
+ 	[WF_ETBF_BASE]		= { { 0x820ea000, 0x820fa000, 0x830ea000 } },
+ 	[WF_LPON_BASE]		= { { 0x820eb000, 0x820fb000, 0x830eb000 } },
+ 	[WF_MIB_BASE]		= { { 0x820ed000, 0x820fd000, 0x830ed000 } },
++	[WF_RATE_BASE]		= { { 0x820ee000, 0x820fe000, 0x830ee000 } },
+ };
+ 
+ static const struct __map mt7996_reg_map[] = {
+diff --git a/mt7996/regs.h b/mt7996/regs.h
+index 42980b9..7a28cae 100644
+--- a/mt7996/regs.h
++++ b/mt7996/regs.h
+@@ -33,6 +33,7 @@ enum base_rev {
+ 	WF_ETBF_BASE,
+ 	WF_LPON_BASE,
+ 	WF_MIB_BASE,
++	WF_RATE_BASE,
+ 	__MT_REG_BASE_MAX,
+ };
+ 
+@@ -235,13 +236,6 @@ enum base_rev {
+ 						 FIELD_PREP(MT_WTBL_LMAC_ID, _id) | \
+ 						 FIELD_PREP(MT_WTBL_LMAC_DW, _dw))
+ 
+-/* AGG: band 0(0x820e2000), band 1(0x820f2000), band 2(0x830e2000) */
+-#define MT_WF_AGG_BASE(_band)			__BASE(WF_AGG_BASE, (_band))
+-#define MT_WF_AGG(_band, ofs)			(MT_WF_AGG_BASE(_band) + (ofs))
+-
+-#define MT_AGG_ACR0(_band)			MT_WF_AGG(_band, 0x054)
+-#define MT_AGG_ACR_CFEND_RATE			GENMASK(13, 0)
+-
+ /* ARB: band 0(0x820e3000), band 1(0x820f3000), band 2(0x830e3000) */
+ #define MT_WF_ARB_BASE(_band)			__BASE(WF_ARB_BASE, (_band))
+ #define MT_WF_ARB(_band, ofs)			(MT_WF_ARB_BASE(_band) + (ofs))
+@@ -300,6 +294,13 @@ enum base_rev {
+ #define MT_WF_RMAC_RSVD0(_band)			MT_WF_RMAC(_band, 0x03e0)
+ #define MT_WF_RMAC_RSVD0_EIFS_CLR		BIT(21)
+ 
++/* RATE: band 0(0x820ee000), band 1(0x820fe000), band 2(0x830ee000) */
++#define MT_WF_RATE_BASE(_band)			__BASE(WF_RATE_BASE, (_band))
++#define MT_WF_RATE(_band, ofs)			(MT_WF_RATE_BASE(_band) + (ofs))
++
++#define MT_RATE_HRCR0(_band)			MT_WF_RATE(_band, 0x050)
++#define MT_RATE_HRCR0_CFEND_RATE		GENMASK(14, 0)
++
+ /* WFDMA0 */
+ #define MT_WFDMA0_BASE				0xd4000
+ #define MT_WFDMA0(ofs)				(MT_WFDMA0_BASE + (ofs))
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0003-wifi-mt76-mt7996-do-not-hardcode-vht-beamform-cap.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0003-wifi-mt76-mt7996-do-not-hardcode-vht-beamform-cap.patch
new file mode 100644
index 0000000..4d9142b
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0003-wifi-mt76-mt7996-do-not-hardcode-vht-beamform-cap.patch
@@ -0,0 +1,29 @@
+From bc54af3f8657ee2633a1c976247fb8d2f07ad568 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Fri, 9 Dec 2022 16:38:03 +0800
+Subject: [PATCH 3/7] wifi: mt76: mt7996: do not hardcode vht beamform cap
+
+Use the sts variable when setting vht beamform sts cap.
+
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+Change-Id: Idbc52c144220ee855251d4a316e475510cfdadad
+---
+ mt7996/init.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mt7996/init.c b/mt7996/init.c
+index 64e8dfd..7a9692a 100644
+--- a/mt7996/init.c
++++ b/mt7996/init.c
+@@ -465,7 +465,7 @@ void mt7996_set_stream_vht_txbf_caps(struct mt7996_phy *phy)
+ 
+ 	*cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
+ 		IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE |
+-		(3 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT);
++		FIELD_PREP(IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK, sts - 1);
+ 
+ 	*cap &= ~(IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK |
+ 		  IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0004-wifi-mt76-connac-fix-POWER_CTRL-command-name-typo.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0004-wifi-mt76-connac-fix-POWER_CTRL-command-name-typo.patch
new file mode 100644
index 0000000..55c75e5
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0004-wifi-mt76-connac-fix-POWER_CTRL-command-name-typo.patch
@@ -0,0 +1,44 @@
+From 5842d6dc7b6644545dac3444a522910a87df7e2b Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Fri, 9 Dec 2022 16:22:16 +0800
+Subject: [PATCH 4/7] wifi: mt76: connac: fix POWER_CTRL command name typo
+
+Fix typo MCU_UNI_CMD_POWER_CREL to MCU_UNI_CMD_POWER_CTRL.
+
+Fixes: 779d34de055e ("wifi: mt76: connac: add more unified command IDs")
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+Change-Id: I89f9e930be97acb91b456c6361b8fb818fe6cbda
+---
+ mt76_connac_mcu.h | 2 +-
+ mt7996/mcu.c      | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
+index f1e942b..82fdf6d 100644
+--- a/mt76_connac_mcu.h
++++ b/mt76_connac_mcu.h
+@@ -1198,7 +1198,7 @@ enum {
+ 	MCU_UNI_CMD_REPT_MUAR = 0x09,
+ 	MCU_UNI_CMD_WSYS_CONFIG = 0x0b,
+ 	MCU_UNI_CMD_REG_ACCESS = 0x0d,
+-	MCU_UNI_CMD_POWER_CREL = 0x0f,
++	MCU_UNI_CMD_POWER_CTRL = 0x0f,
+ 	MCU_UNI_CMD_RX_HDR_TRANS = 0x12,
+ 	MCU_UNI_CMD_SER = 0x13,
+ 	MCU_UNI_CMD_TWT = 0x14,
+diff --git a/mt7996/mcu.c b/mt7996/mcu.c
+index a88fc76..d781c6e 100644
+--- a/mt7996/mcu.c
++++ b/mt7996/mcu.c
+@@ -2399,7 +2399,7 @@ mt7996_mcu_restart(struct mt76_dev *dev)
+ 		.power_mode = 1,
+ 	};
+ 
+-	return mt76_mcu_send_msg(dev, MCU_WM_UNI_CMD(POWER_CREL), &req,
++	return mt76_mcu_send_msg(dev, MCU_WM_UNI_CMD(POWER_CTRL), &req,
+ 				 sizeof(req), false);
+ }
+ 
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4001-mt76-mt7996-for-build-pass.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4001-mt76-mt7996-for-build-pass.patch
new file mode 100644
index 0000000..3f327fc
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4001-mt76-mt7996-for-build-pass.patch
@@ -0,0 +1,67 @@
+From c7c415e89ab0e47caa0d0a8d6b62bc179a16c35a Mon Sep 17 00:00:00 2001
+From: Evelyn Tsai <evelyn.tsai@mediatek.com>
+Date: Fri, 23 Dec 2022 17:28:03 +0800
+Subject: [PATCH 4001/4003] mt76: mt7996: for build pass
+
+---
+ debugfs.c    | 3 +++
+ dma.c        | 4 ++--
+ mt7996/dma.c | 4 ++--
+ 3 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/debugfs.c b/debugfs.c
+index 79064a4..e10d4cb 100644
+--- a/debugfs.c
++++ b/debugfs.c
+@@ -33,8 +33,11 @@ mt76_napi_threaded_set(void *data, u64 val)
+ 	if (!mt76_is_mmio(dev))
+ 		return -EOPNOTSUPP;
+ 
++#if 0
++	/* need to backport patch from networking stack */
+ 	if (dev->napi_dev.threaded != val)
+ 		return dev_set_threaded(&dev->napi_dev, val);
++#endif
+ 
+ 	return 0;
+ }
+diff --git a/dma.c b/dma.c
+index fc24b35..beb03cd 100644
+--- a/dma.c
++++ b/dma.c
+@@ -627,7 +627,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
+ 
+ 	switch (type) {
+ 	case MT76_WED_Q_TX:
+-		ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs);
++		ret = mtk_wed_device_tx_ring_setup(wed, ring, q->regs, 0);
+ 		if (!ret)
+ 			q->wed_regs = wed->tx_ring[ring].reg_base;
+ 		break;
+@@ -643,7 +643,7 @@ mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q)
+ 			q->wed_regs = wed->txfree_ring.reg_base;
+ 		break;
+ 	case MT76_WED_Q_RX:
+-		ret = mtk_wed_device_rx_ring_setup(wed, ring, q->regs);
++		ret = mtk_wed_device_rx_ring_setup(wed, ring, q->regs, 0);
+ 		if (!ret)
+ 			q->wed_regs = wed->rx_ring[ring].reg_base;
+ 		break;
+diff --git a/mt7996/dma.c b/mt7996/dma.c
+index c09fe42..8c2e060 100644
+--- a/mt7996/dma.c
++++ b/mt7996/dma.c
+@@ -343,8 +343,8 @@ int mt7996_dma_init(struct mt7996_dev *dev)
+ 	if (ret < 0)
+ 		return ret;
+ 
+-	netif_napi_add_tx(&dev->mt76.tx_napi_dev, &dev->mt76.tx_napi,
+-			  mt7996_poll_tx);
++	netif_tx_napi_add(&dev->mt76.tx_napi_dev, &dev->mt76.tx_napi,
++			  mt7996_poll_tx, NAPI_POLL_WEIGHT);
+ 	napi_enable(&dev->mt76.tx_napi);
+ 
+ 	mt7996_dma_enable(dev);
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4002-mt76-revert-get_of_mac_addr.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4002-mt76-revert-get_of_mac_addr.patch
new file mode 100644
index 0000000..ad2ac2e
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4002-mt76-revert-get_of_mac_addr.patch
@@ -0,0 +1,33 @@
+From 4b50024ac0c221561d57a947fa6e76faf613c1a6 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Tue, 13 Dec 2022 10:51:46 +0800
+Subject: [PATCH 4002/4003] mt76: revert get_of_mac_addr
+
+---
+ eeprom.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/eeprom.c b/eeprom.c
+index 0a88048..680f76f 100644
+--- a/eeprom.c
++++ b/eeprom.c
+@@ -106,9 +106,15 @@ void
+ mt76_eeprom_override(struct mt76_phy *phy)
+ {
+ 	struct mt76_dev *dev = phy->dev;
++#ifdef CONFIG_OF
+ 	struct device_node *np = dev->dev->of_node;
++	const u8 *mac = NULL;
+ 
+-	of_get_mac_address(np, phy->macaddr);
++	if (np)
++		mac = of_get_mac_address(np);
++	if (!IS_ERR_OR_NULL(mac))
++		ether_addr_copy(phy->macaddr, mac);
++#endif
+ 
+ 	if (!is_valid_ether_addr(phy->macaddr)) {
+ 		eth_random_addr(phy->macaddr);
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4003-mt76-include-header-files-for-module-param.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4003-mt76-include-header-files-for-module-param.patch
new file mode 100644
index 0000000..6fc5e0b
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/4003-mt76-include-header-files-for-module-param.patch
@@ -0,0 +1,76 @@
+From 6ca19bb406e52edaed41d8ea84f67e872df113a4 Mon Sep 17 00:00:00 2001
+From: Evelyn Tsai <evelyn.tsai@mediatek.com>
+Date: Fri, 23 Dec 2022 17:06:03 +0800
+Subject: [PATCH 4003/4003] mt76: include header files for module param
+
+---
+ mcu.c             | 1 +
+ mt7615/mcu.c      | 1 +
+ mt76_connac_mcu.c | 1 +
+ mt7915/mcu.c      | 1 +
+ mt7996/mcu.c      | 1 +
+ 5 files changed, 5 insertions(+)
+
+diff --git a/mcu.c b/mcu.c
+index a8cafa3..fa4b054 100644
+--- a/mcu.c
++++ b/mcu.c
+@@ -4,6 +4,7 @@
+  */
+ 
+ #include "mt76.h"
++#include <linux/moduleparam.h>
+ 
+ struct sk_buff *
+ __mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
+diff --git a/mt7615/mcu.c b/mt7615/mcu.c
+index 83f3030..e917d02 100644
+--- a/mt7615/mcu.c
++++ b/mt7615/mcu.c
+@@ -10,6 +10,7 @@
+ #include "mcu.h"
+ #include "mac.h"
+ #include "eeprom.h"
++#include <linux/moduleparam.h>
+ 
+ static bool prefer_offload_fw = true;
+ module_param(prefer_offload_fw, bool, 0644);
+diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
+index 5a047e6..b0dcc5a 100644
+--- a/mt76_connac_mcu.c
++++ b/mt76_connac_mcu.c
+@@ -4,6 +4,7 @@
+ #include <linux/firmware.h>
+ #include "mt76_connac2_mac.h"
+ #include "mt76_connac_mcu.h"
++#include <linux/module.h>
+ 
+ int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option)
+ {
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index 35441dc..56b5a24 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -6,6 +6,7 @@
+ #include "mcu.h"
+ #include "mac.h"
+ #include "eeprom.h"
++#include <linux/moduleparam.h>
+ 
+ #define fw_name(_dev, name, ...)	({			\
+ 	char *_fw;						\
+diff --git a/mt7996/mcu.c b/mt7996/mcu.c
+index d781c6e..37cf269 100644
+--- a/mt7996/mcu.c
++++ b/mt7996/mcu.c
+@@ -8,6 +8,7 @@
+ #include "mt7996.h"
+ #include "mcu.h"
+ #include "mac.h"
++#include <linux/moduleparam.h>
+ #include "eeprom.h"
+ 
+ struct mt7996_patch_hdr {
+-- 
+2.36.1
+