[Refactor and sync wifi from Openwrt]

[Description]
Refactor and sync wifi from Openwrt
1.mt76/mac80211/hostapd

[Release-log]
N/A

diff --git a/recipes-kernel/linux-mt76/files/patches/0008-mt76-mt7915-disable-mt7986-rx-hdr-trans-short.patch b/recipes-kernel/linux-mt76/files/patches/0008-mt76-mt7915-disable-mt7986-rx-hdr-trans-short.patch
deleted file mode 100644
index ba8919b..0000000
--- a/recipes-kernel/linux-mt76/files/patches/0008-mt76-mt7915-disable-mt7986-rx-hdr-trans-short.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 00e4fb5cf4d22681b379cdb92e0750cf74b367e7 Mon Sep 17 00:00:00 2001
-From: "lian.chen" <lian.chen@mediatek.com>
-Date: Wed, 16 Mar 2022 15:14:05 +0800
-Subject: [PATCH] mt76: mt7915: disable mt7986 RX_HDR_TRANS_SHORT
-
-Signed-off-by: lian.chen <lian.chen@mediatek.com>
----
- mt7915/init.c | 3 +++
- mt7915/mac.c  | 4 ----
- mt7915/regs.h | 3 +++
- 3 files changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/mt7915/init.c b/mt7915/init.c
-index f57a3d18..223a4f77 100644
---- a/mt7915/init.c
-+++ b/mt7915/init.c
-@@ -451,6 +451,9 @@ static void mt7915_mac_init(struct mt7915_dev *dev)
- 
- 	mt76_rmw_field(dev, MT_MDP_DCR1, MT_MDP_DCR1_MAX_RX_LEN, rx_len);
- 
-+	/* disable RX_TRANS_SHORT */
-+	mt76_clear(dev, MT_MDP_DCR2, MT_MDP_DCR2_RX_TRANS_SHORT);
-+
- 	/* enable hardware de-agg */
- 	mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_DAMSDU_EN);
- 
-diff --git a/mt7915/mac.c b/mt7915/mac.c
-index fe718102..eedd901f 100644
---- a/mt7915/mac.c
-+++ b/mt7915/mac.c
-@@ -835,10 +835,6 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
- 	if (!status->wcid || !ieee80211_is_data_qos(fc))
- 		return 0;
- 
--	/* drop no data frame */
--	if (fc & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))
--		return -EINVAL;
--
- 	status->aggr = unicast &&
- 		       !ieee80211_is_qos_nullfunc(fc);
- 	status->qos_ctl = qos_ctl;
-diff --git a/mt7915/regs.h b/mt7915/regs.h
-index e7d83458..6ddfa48f 100644
---- a/mt7915/regs.h
-+++ b/mt7915/regs.h
-@@ -159,6 +159,9 @@ enum offs_rev {
- #define MT_MDP_DCR1			MT_MDP(0x004)
- #define MT_MDP_DCR1_MAX_RX_LEN		GENMASK(15, 3)
- 
-+#define MT_MDP_DCR2			MT_MDP(0x0e8)
-+#define MT_MDP_DCR2_RX_TRANS_SHORT		BIT(2)
-+
- #define MT_MDP_BNRCFR0(_band)		MT_MDP(__OFFS(MDP_BNRCFR0) + \
- 					       ((_band) << 8))
- #define MT_MDP_RCFR0_MCU_RX_MGMT	GENMASK(5, 4)
--- 
-2.18.0
-
diff --git a/recipes-kernel/linux-mt76/files/patches/0011-mt76-mt7915-add-list_del_init-msta-wcid.list.patch b/recipes-kernel/linux-mt76/files/patches/0011-mt76-mt7915-add-list_del_init-msta-wcid.list.patch
deleted file mode 100755
index 0ea18c1..0000000
--- a/recipes-kernel/linux-mt76/files/patches/0011-mt76-mt7915-add-list_del_init-msta-wcid.list.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 95953b3adaadf15ad5ae637d4e0e433c3bfb0835 Mon Sep 17 00:00:00 2001
-From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Thu, 31 Mar 2022 11:23:02 +0800
-Subject: [PATCH] mt76: mt7915: add list_del_init(&msta->wcid.list)
-
-msta->wcid may use after free when do mt76_tx_status_check
-
-Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
----
- mt7915/main.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/mt7915/main.c b/mt7915/main.c
-index 9de5f152..fc271e3c 100644
---- a/mt7915/main.c
-+++ b/mt7915/main.c
-@@ -729,6 +729,11 @@ void mt7915_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
- 	if (!list_empty(&msta->rc_list))
- 		list_del_init(&msta->rc_list);
- 	spin_unlock_bh(&dev->sta_poll_lock);
-+
-+	spin_lock_bh(&mdev->status_lock);
-+	if (!list_empty(&msta->wcid.list))
-+		list_del_init(&msta->wcid.list);
-+	spin_unlock_bh(&mdev->status_lock);
- }
- 
- static void mt7915_tx(struct ieee80211_hw *hw,
--- 
-2.18.0
-
diff --git a/recipes-kernel/linux-mt76/files/patches/0013-mt76-mt7915-report-qos_ctl-without-ACK-policy-to-the.patch b/recipes-kernel/linux-mt76/files/patches/0013-mt76-mt7915-report-qos_ctl-without-ACK-policy-to-the.patch
deleted file mode 100755
index 62b0c20..0000000
--- a/recipes-kernel/linux-mt76/files/patches/0013-mt76-mt7915-report-qos_ctl-without-ACK-policy-to-the.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From fcd6f43e0a3de4829397efe19cedf759d091beac Mon Sep 17 00:00:00 2001
-From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Mon, 11 Apr 2022 20:03:09 +0800
-Subject: [PATCH] mt76: mt7915: report qos_ctl without ACK policy to the up
- layer
-
-There is no need to report the ACK policy to the
-mac80211 layer, because hw has already processed it
-
-Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
----
- mt7915/mac.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 8df38a23..64ef061f 100644
---- a/mt7915/mac.c
-+++ b/mt7915/mac.c
-@@ -680,9 +680,14 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
- 		u32 v2 = le32_to_cpu(rxd[2]);
- 
- 		fc = cpu_to_le16(FIELD_GET(MT_RXD6_FRAME_CONTROL, v0));
--		qos_ctl = FIELD_GET(MT_RXD8_QOS_CTL, v2);
- 		seq_ctrl = FIELD_GET(MT_RXD8_SEQ_CTRL, v2);
- 
-+		/*
-+		 * There is no need to report the ACK policy to the
-+		 * mac80211 layer, because hw has already processed it.
-+		 */
-+		qos_ctl = FIELD_GET(MT_RXD8_QOS_CTL, v2) & IEEE80211_QOS_CTL_TID_MASK;
-+
- 		rxd += 4;
- 		if ((u8 *)rxd - skb->data >= skb->len)
- 			return -EINVAL;
--- 
-2.18.0
-
diff --git a/recipes-kernel/linux-mt76/files/patches/1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch b/recipes-kernel/linux-mt76/files/patches/1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch
old mode 100644
new mode 100755
index e615e9c..c912a30
--- a/recipes-kernel/linux-mt76/files/patches/1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch
+++ b/recipes-kernel/linux-mt76/files/patches/1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch
@@ -1,27 +1,29 @@
-From 3dd7344c6aa1124982d81d98defea6263899673b Mon Sep 17 00:00:00 2001
-From: Shayne Chen <shayne.chen@mediatek.com>
-Date: Thu, 17 Feb 2022 00:17:39 +0800
+From f45027dc3cee106b6119d1343f036eca4a00d9f8 Mon Sep 17 00:00:00 2001
+From: Bo Jiao <Bo.Jiao@mediatek.com>
+Date: Thu, 21 Apr 2022 19:42:55 +0800
 Subject: [PATCH] mt76: mt7915: add mtk internal debug tools for mt76
 
+Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
 ---
- .../wireless/mediatek/mt76/mt76_connac_mcu.h  |    6 +
- .../wireless/mediatek/mt76/mt7915/Makefile    |    2 +-
- .../wireless/mediatek/mt76/mt7915/debugfs.c   |   72 +-
- .../net/wireless/mediatek/mt76/mt7915/mac.c   |   14 +
- .../net/wireless/mediatek/mt76/mt7915/mcu.c   |   41 +
- .../net/wireless/mediatek/mt76/mt7915/mcu.h   |    4 +
- .../wireless/mediatek/mt76/mt7915/mt7915.h    |   41 +
- .../mediatek/mt76/mt7915/mt7915_debug.h       | 1350 ++++++++
- .../mediatek/mt76/mt7915/mtk_debugfs.c        | 2893 +++++++++++++++++
- .../wireless/mediatek/mt76/mt7915/mtk_mcu.c   |   51 +
- .../net/wireless/mediatek/mt76/tools/fwlog.c  |   26 +-
+ mt76_connac_mcu.h     |    6 +
+ mt7915/Makefile       |    2 +-
+ mt7915/debugfs.c      |   72 +-
+ mt7915/mac.c          |   14 +
+ mt7915/mcu.c          |   41 +
+ mt7915/mcu.h          |    4 +
+ mt7915/mt7915.h       |   41 +
+ mt7915/mt7915_debug.h | 1350 +++++++++++++++++++
+ mt7915/mtk_debugfs.c  | 2893 +++++++++++++++++++++++++++++++++++++++++
+ mt7915/mtk_mcu.c      |   51 +
+ tools/fwlog.c         |   26 +-
  11 files changed, 4489 insertions(+), 11 deletions(-)
- create mode 100644 drivers/net/wireless/mediatek/mt76/mt7915/mt7915_debug.h
- create mode 100644 drivers/net/wireless/mediatek/mt76/mt7915/mtk_debugfs.c
- create mode 100644 drivers/net/wireless/mediatek/mt76/mt7915/mtk_mcu.c
+ mode change 100644 => 100755 mt7915/mcu.c
+ create mode 100644 mt7915/mt7915_debug.h
+ create mode 100644 mt7915/mtk_debugfs.c
+ create mode 100644 mt7915/mtk_mcu.c
 
 diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
-index 54419864..494c5c71 100644
+index aa14d2d4..03134066 100644
 --- a/mt76_connac_mcu.h
 +++ b/mt76_connac_mcu.h
 @@ -968,6 +968,12 @@ enum {
@@ -52,7 +54,7 @@
  mt7915e-$(CONFIG_MT7986_WMAC) += soc.o
 \ No newline at end of file
 diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
-index 4e1ecaec..6df148c5 100644
+index 77bbeeed..e8e26ac1 100644
 --- a/mt7915/debugfs.c
 +++ b/mt7915/debugfs.c
 @@ -8,6 +8,9 @@
@@ -128,7 +130,7 @@
  	return mt7915_fw_debug_wm_set(dev, dev->fw_debug_wm);
  }
  
-@@ -910,6 +939,11 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
+@@ -942,6 +971,11 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
  	if (!ext_phy)
  		dev->debugfs_dir = dir;
  
@@ -140,7 +142,7 @@
  	return 0;
  }
  
-@@ -950,17 +984,53 @@ void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int
+@@ -982,17 +1016,53 @@ void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int
  		.msg_type = cpu_to_le16(PKT_TYPE_RX_FW_MONITOR),
  	};
  
@@ -195,10 +197,10 @@
  
  	if (dev->relay_fwlog)
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 887292da..6f4cc947 100644
+index c1ff04ae..e8899590 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
-@@ -595,6 +595,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -596,6 +596,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
  	__le16 fc = 0;
  	int idx;
  
@@ -209,7 +211,7 @@
  	memset(status, 0, sizeof(*status));
  
  	if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->band_idx) {
-@@ -778,6 +782,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -785,6 +789,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
  	}
  
  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
@@ -220,7 +222,7 @@
  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
  		if (mt7915_reverse_frag0_hdr_trans(skb, hdr_gap))
  			return -EINVAL;
-@@ -1343,6 +1351,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
+@@ -1351,6 +1359,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
  	tx_info->buf[1].skip_unmap = true;
  	tx_info->nbuf = MT_CT_DMA_BUF_NUM;
  
@@ -234,7 +236,9 @@
  }
  
 diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index 549281a4..15a6fe5a 100644
+old mode 100644
+new mode 100755
+index c215bc9e..bce14f4b
 --- a/mt7915/mcu.c
 +++ b/mt7915/mcu.c
 @@ -298,6 +298,10 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
@@ -248,11 +252,10 @@
  	if (wait_seq)
  		*wait_seq = seq;
  
-@@ -3613,3 +3617,40 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
- 	return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE),
+@@ -3660,6 +3664,43 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
  				 &req, sizeof(req), true);
  }
-+
+ 
 +#ifdef MTK_DEBUG
 +int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp)
 +{
@@ -289,8 +292,12 @@
 +	return 0;
 +}
 +#endif
++
+ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
+ {
+ 	struct {
 diff --git a/mt7915/mcu.h b/mt7915/mcu.h
-index 52368dc3..94e0a81b 100644
+index df7aefca..c36cf511 100644
 --- a/mt7915/mcu.h
 +++ b/mt7915/mcu.h
 @@ -296,6 +296,10 @@ enum {
@@ -305,7 +312,7 @@
  
  enum mcu_mmps_mode {
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 6efa0a2e..8bcd861f 100644
+index e5f89161..92fedaf3 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -9,6 +9,7 @@
@@ -344,7 +351,7 @@
  };
  
  enum {
-@@ -593,4 +615,23 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+@@ -595,4 +617,23 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  			    struct ieee80211_sta *sta, struct dentry *dir);
  #endif
  
@@ -4766,5 +4773,5 @@
  	return ret;
  }
 -- 
-2.25.1
+2.18.0
 
diff --git a/recipes-kernel/linux-mt76/files/patches/1100-mt76-testmode-support-eeprom-handle.patch b/recipes-kernel/linux-mt76/files/patches/1100-mt76-testmode-support-eeprom-handle.patch
index ee5b283..995777b 100755
--- a/recipes-kernel/linux-mt76/files/patches/1100-mt76-testmode-support-eeprom-handle.patch
+++ b/recipes-kernel/linux-mt76/files/patches/1100-mt76-testmode-support-eeprom-handle.patch
@@ -1,7 +1,7 @@
-From b6c6afbe347c8cd3ab43d4cab07e840ecf5d3ad6 Mon Sep 17 00:00:00 2001
+From 223df0027748514563ede33a1283e5c1b9fbc342 Mon Sep 17 00:00:00 2001
 From: Shayne Chen <shayne.chen@mediatek.com>
 Date: Tue, 29 Jun 2021 14:30:44 +0800
-Subject: [PATCH 1100/1112] mt76: testmode: support eeprom handle
+Subject: [PATCH 1/2] mt76: testmode: support eeprom handle
 
 Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
 ---
@@ -15,10 +15,10 @@
  7 files changed, 133 insertions(+), 7 deletions(-)
 
 diff --git a/mt76.h b/mt76.h
-index 58b324c..8ad7674 100644
+index 8f6279c5..6d78e7bf 100644
 --- a/mt76.h
 +++ b/mt76.h
-@@ -581,6 +581,7 @@ struct mt76_testmode_ops {
+@@ -602,6 +602,7 @@ struct mt76_testmode_ops {
  	int (*set_params)(struct mt76_phy *phy, struct nlattr **tb,
  			  enum mt76_testmode_state new_state);
  	int (*dump_stats)(struct mt76_phy *phy, struct sk_buff *msg);
@@ -27,10 +27,10 @@
  
  #define MT_TM_FW_RX_COUNT	BIT(0)
 diff --git a/mt7915/init.c b/mt7915/init.c
-index cd69174..92d57f9 100644
+index 0b36083e..79dae0fc 100644
 --- a/mt7915/init.c
 +++ b/mt7915/init.c
-@@ -569,7 +569,7 @@ static void mt7915_init_work(struct work_struct *work)
+@@ -573,7 +573,7 @@ static void mt7915_init_work(struct work_struct *work)
  	struct mt7915_dev *dev = container_of(work, struct mt7915_dev,
  				 init_work);
  
@@ -40,7 +40,7 @@
  	mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband);
  	mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband);
 diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index d55e9d0..2b57459 100644
+index 777fd890..681ede23 100755
 --- a/mt7915/mcu.c
 +++ b/mt7915/mcu.c
 @@ -289,7 +289,6 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
@@ -51,7 +51,7 @@
  		if (cmd & __MCU_CMD_FIELD_QUERY)
  			mcu_txd->set_query = MCU_Q_QUERY;
  		else
-@@ -2913,14 +2912,14 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
+@@ -2955,14 +2954,14 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev)
  	return 0;
  }
  
@@ -69,10 +69,10 @@
  
  	return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(EFUSE_BUFFER_MODE),
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index a8726fe..274afff 100644
+index 09710562..24276da5 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
-@@ -539,7 +539,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
+@@ -549,7 +549,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
  				   struct ieee80211_vif *vif,
  				   struct ieee80211_sta *sta,
  				   void *data, u32 field);
@@ -82,7 +82,7 @@
  int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
  int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
 diff --git a/mt7915/testmode.c b/mt7915/testmode.c
-index e8bf616..2c859f6 100644
+index e8bf616c..a91f7e55 100644
 --- a/mt7915/testmode.c
 +++ b/mt7915/testmode.c
 @@ -848,8 +848,62 @@ mt7915_tm_dump_stats(struct mt76_phy *mphy, struct sk_buff *msg)
@@ -100,7 +100,7 @@
 +	if (mt76_chip(&dev->mt76) != get_unaligned_le16(eeprom))
 +		goto out;
 +
-+	for (i = 0; i < MT7915_EEPROM_SIZE; i += MT76_TM_EEPROM_BLOCK_SIZE) {
++	for (i = 0; i < mt7915_eeprom_size(dev); i += MT76_TM_EEPROM_BLOCK_SIZE) {
 +		req.addr = cpu_to_le32(i);
 +		memcpy(&req.data, eeprom + i, MT76_TM_EEPROM_BLOCK_SIZE);
 +
@@ -122,7 +122,7 @@
 +	u8 *eeprom = dev->mt76.eeprom.data;
 +	int ret = 0;
 +
-+	if (offset >= MT7915_EEPROM_SIZE)
++	if (offset >= mt7915_eeprom_size(dev))
 +		return -EINVAL;
 +
 +	switch (action) {
@@ -149,7 +149,7 @@
 +	.set_eeprom = mt7915_tm_set_eeprom,
  };
 diff --git a/testmode.c b/testmode.c
-index e6d1f70..1fbca66 100644
+index e6d1f702..1fbca660 100644
 --- a/testmode.c
 +++ b/testmode.c
 @@ -402,6 +402,44 @@ mt76_tm_get_u8(struct nlattr *attr, u8 *dest, u8 min, u8 max)
@@ -220,7 +220,7 @@
  		nla_for_each_nested(cur, tb[MT76_TM_ATTR_TX_POWER], rem) {
  			if (nla_len(cur) != 1 ||
 diff --git a/testmode.h b/testmode.h
-index 8961326..5900c76 100644
+index 89613266..5900c762 100644
 --- a/testmode.h
 +++ b/testmode.h
 @@ -6,6 +6,7 @@
diff --git a/recipes-kernel/linux-mt76/files/patches/1101-mt76-enable-more-5g-channels.patch b/recipes-kernel/linux-mt76/files/patches/1101-mt76-enable-more-5g-channels.patch
index c8f5b55..0faa2c1 100755
--- a/recipes-kernel/linux-mt76/files/patches/1101-mt76-enable-more-5g-channels.patch
+++ b/recipes-kernel/linux-mt76/files/patches/1101-mt76-enable-more-5g-channels.patch
@@ -1,30 +1,20 @@
-From a45a4416976cd7604bf90103e24fe78150b9de6f Mon Sep 17 00:00:00 2001
+From 8316325d23bebf7fbc408380bd514455b2c8a74a Mon Sep 17 00:00:00 2001
 From: Shayne Chen <shayne.chen@mediatek.com>
 Date: Wed, 29 Sep 2021 14:03:02 +0800
-Subject: [PATCH 1101/1112] mt76: enable more 5g channels
+Subject: [PATCH 2/2] mt76: enable more 5g channels
 
 This is necessary for testmode.
 
 Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
 ---
- drivers/net/wireless/mediatek/mt76/mac80211.c | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
+ drivers/net/wireless/mediatek/mt76/mac80211.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
 
 diff --git a/mac80211.c b/mac80211.c
-index 89ca644..e473227 100644
+index 0b274930..b984e0dc 100644
 --- a/mac80211.c
 +++ b/mac80211.c
-@@ -45,6 +45,9 @@ static const struct ieee80211_channel mt76_channels_2ghz[] = {
- };
- 
- static const struct ieee80211_channel mt76_channels_5ghz[] = {
-+	CHAN5G(12, 5060),
-+	CHAN5G(16, 5080),
-+
- 	CHAN5G(36, 5180),
- 	CHAN5G(40, 5200),
- 	CHAN5G(44, 5220),
-@@ -55,6 +58,13 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
+@@ -55,6 +55,13 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
  	CHAN5G(60, 5300),
  	CHAN5G(64, 5320),
  
@@ -38,7 +28,7 @@
  	CHAN5G(100, 5500),
  	CHAN5G(104, 5520),
  	CHAN5G(108, 5540),
-@@ -75,6 +85,11 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
+@@ -75,6 +82,11 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
  	CHAN5G(165, 5825),
  	CHAN5G(169, 5845),
  	CHAN5G(173, 5865),
diff --git a/recipes-kernel/linux-mt76/files/patches/1112-mt76-mt7915-add-L0.5-SER-for-mt7986.patch b/recipes-kernel/linux-mt76/files/patches/1112-mt76-mt7915-add-L0.5-SER-for-mt7986.patch
index 0b0e0f0..73b6c15 100644
--- a/recipes-kernel/linux-mt76/files/patches/1112-mt76-mt7915-add-L0.5-SER-for-mt7986.patch
+++ b/recipes-kernel/linux-mt76/files/patches/1112-mt76-mt7915-add-L0.5-SER-for-mt7986.patch
@@ -1,8 +1,9 @@
-From dd9c922fc167858afc7ac23dd180cc45821a3501 Mon Sep 17 00:00:00 2001
+From 410b8c158d29137df0da4d8a1e82d494528e4fb1 Mon Sep 17 00:00:00 2001
 From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Mon, 28 Mar 2022 09:28:30 +0800
+Date: Mon, 25 Apr 2022 10:19:29 +0800
 Subject: [PATCH] mt76: mt7915: add L0.5 SER for mt7986
 
+Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
 ---
  mt7915/debugfs.c | 168 +++++++++++++++++++++++++++++++++-
  mt7915/dma.c     |  49 ++++++++++
@@ -16,7 +17,7 @@
  9 files changed, 572 insertions(+), 28 deletions(-)
 
 diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
-index 6df148c5..57754105 100644
+index e8e26ac1..003aacaa 100644
 --- a/mt7915/debugfs.c
 +++ b/mt7915/debugfs.c
 @@ -47,7 +47,8 @@ mt7915_implicit_txbf_get(void *data, u64 *val)
@@ -117,25 +118,25 @@
 +	msleep(100);
 +
 +	seq_printf(s, "::E  R , SER_STATUS        = 0x%08X\n",
-+		   MT_SWDEF_SER_STATUS);
++		   mt76_rr(dev, MT_SWDEF_SER_STATUS));
 +	seq_printf(s, "::E  R , SER_PLE_ERR       = 0x%08X\n",
-+		   MT_SWDEF_PLE_STATUS);
++		   mt76_rr(dev, MT_SWDEF_PLE_STATUS));
 +	seq_printf(s, "::E  R , SER_PLE_ERR_1     = 0x%08X\n",
-+		   MT_SWDEF_PLE1_STATUS);
++		   mt76_rr(dev, MT_SWDEF_PLE1_STATUS));
 +	seq_printf(s, "::E  R , SER_PLE_ERR_AMSDU = 0x%08X\n",
-+		   MT_SWDEF_PLE_AMSDU_STATUS);
++		   mt76_rr(dev, MT_SWDEF_PLE_AMSDU_STATUS));
 +	seq_printf(s, "::E  R , SER_PSE_ERR       = 0x%08X\n",
-+		   MT_SWDEF_PSE_STATUS);
++		   mt76_rr(dev, MT_SWDEF_PSE_STATUS));
 +	seq_printf(s, "::E  R , SER_PSE_ERR_1     = 0x%08X\n",
-+		   MT_SWDEF_PSE1_STATUS);
++		   mt76_rr(dev, MT_SWDEF_PSE1_STATUS));
 +	seq_printf(s, "::E  R , SER_LMAC_WISR6_B0 = 0x%08X\n",
-+		   MT_SWDEF_LAMC_WISR6_BN0_STATUS);
++		   mt76_rr(dev, MT_SWDEF_LAMC_WISR6_BN0_STATUS));
 +	seq_printf(s, "::E  R , SER_LMAC_WISR6_B1 = 0x%08X\n",
-+		   MT_SWDEF_LAMC_WISR6_BN1_STATUS);
++		   mt76_rr(dev, MT_SWDEF_LAMC_WISR6_BN1_STATUS));
 +	seq_printf(s, "::E  R , SER_LMAC_WISR7_B0 = 0x%08X\n",
-+		   MT_SWDEF_LAMC_WISR7_BN0_STATUS);
++		   mt76_rr(dev, MT_SWDEF_LAMC_WISR7_BN0_STATUS));
 +	seq_printf(s, "::E  R , SER_LMAC_WISR7_B1 = 0x%08X\n",
-+		   MT_SWDEF_LAMC_WISR7_BN1_STATUS);
++		   mt76_rr(dev, MT_SWDEF_LAMC_WISR7_BN1_STATUS));
 +
 +	seq_printf(s, "\nWF RESET STATUS: WM %d, WA %d, WO %d\n",
 +		   dev->ser.wf_reset_wm_count,
@@ -202,20 +203,20 @@
  static int
  mt7915_radar_trigger(void *data, u64 val)
  {
-@@ -927,6 +1091,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
- 	debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir,
- 				    mt7915_twt_stats);
- 	debugfs_create_file("ser_trigger", 0200, dir, dev, &fops_ser_trigger);
+@@ -943,6 +1107,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
+ 	debugfs_create_file("xmit-queues", 0400, dir, phy,
+ 			    &mt7915_xmit_queues_fops);
+ 	debugfs_create_file("tx_stats", 0400, dir, phy, &mt7915_tx_stats_fops);
 +	debugfs_create_devm_seqfile(dev->mt76.dev, "ser_show", dir,
 +				    mt7915_ser_stats_show);
- 	if (!dev->dbdc_support || phy->band_idx) {
- 		debugfs_create_u32("dfs_hw_pattern", 0400, dir,
- 				   &dev->hw_pattern);
+ 	debugfs_create_file("fw_debug_wm", 0600, dir, dev, &fops_fw_debug_wm);
+ 	debugfs_create_file("fw_debug_wa", 0600, dir, dev, &fops_fw_debug_wa);
+ 	debugfs_create_file("fw_debug_bin", 0600, dir, dev, &fops_fw_debug_bin);
 diff --git a/mt7915/dma.c b/mt7915/dma.c
-index 66a312a9..60b4368a 100644
+index c2d655cd..219b440f 100644
 --- a/mt7915/dma.c
 +++ b/mt7915/dma.c
-@@ -453,6 +453,55 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
+@@ -486,6 +486,55 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
  	return 0;
  }
  
@@ -272,7 +273,7 @@
  {
  	mt7915_dma_disable(dev, true);
 diff --git a/mt7915/init.c b/mt7915/init.c
-index 4d462c3a..03bcb40e 100644
+index 79dae0fc..25a9b5de 100644
 --- a/mt7915/init.c
 +++ b/mt7915/init.c
 @@ -262,7 +262,7 @@ static void mt7915_led_set_brightness(struct led_classdev *led_cdev,
@@ -312,7 +313,7 @@
  
  unreg_thermal:
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index d8578d12..aa312b75 100644
+index b899697c..e301fe52 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
 @@ -3,6 +3,7 @@
@@ -323,7 +324,7 @@
  #include "mt7915.h"
  #include "../dma.h"
  #include "mac.h"
-@@ -1970,9 +1971,9 @@ mt7915_update_beacons(struct mt7915_dev *dev)
+@@ -2064,9 +2065,9 @@ mt7915_update_beacons(struct mt7915_dev *dev)
  		IEEE80211_IFACE_ITER_RESUME_ALL,
  		mt7915_update_vif_beacon, dev->mt76.phy2->hw);
  }
@@ -335,7 +336,7 @@
  {
  	struct mt76_phy *mphy_ext = dev->mt76.phy2;
  	u32 hif1_ofs = MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0);
-@@ -2037,6 +2038,7 @@ mt7915_dma_reset(struct mt7915_dev *dev)
+@@ -2131,6 +2132,7 @@ mt7915_dma_reset(struct mt7915_dev *dev)
  				 MT_WFDMA1_GLO_CFG_OMIT_RX_INFO);
  	}
  }
@@ -343,7 +344,7 @@
  
  void mt7915_tx_token_put(struct mt7915_dev *dev)
  {
-@@ -2052,6 +2054,172 @@ void mt7915_tx_token_put(struct mt7915_dev *dev)
+@@ -2146,6 +2148,172 @@ void mt7915_tx_token_put(struct mt7915_dev *dev)
  	idr_destroy(&dev->mt76.token);
  }
  
@@ -516,7 +517,7 @@
  /* system error recovery */
  void mt7915_mac_reset_work(struct work_struct *work)
  {
-@@ -2063,6 +2231,25 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -2157,6 +2325,25 @@ void mt7915_mac_reset_work(struct work_struct *work)
  	ext_phy = dev->mt76.phy2;
  	phy2 = ext_phy ? ext_phy->priv : NULL;
  
@@ -542,7 +543,7 @@
  	if (!(READ_ONCE(dev->reset_state) & MT_MCU_CMD_STOP_DMA))
  		return;
  
-@@ -2089,7 +2276,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -2183,7 +2370,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
  	mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_STOPPED);
  
  	if (mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) {
@@ -551,7 +552,7 @@
  
  		mt7915_tx_token_put(dev);
  		idr_init(&dev->mt76.token);
-@@ -2140,6 +2327,44 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -2234,6 +2421,44 @@ void mt7915_mac_reset_work(struct work_struct *work)
  					     MT7915_WATCHDOG_TIME);
  }
  
@@ -597,7 +598,7 @@
  {
  	struct mt7915_dev *dev = phy->dev;
 diff --git a/mt7915/main.c b/mt7915/main.c
-index 0816398a..9de5f152 100644
+index 5b0a6d02..9cc60e85 100644
 --- a/mt7915/main.c
 +++ b/mt7915/main.c
 @@ -20,7 +20,7 @@ static bool mt7915_dev_running(struct mt7915_dev *dev)
@@ -618,7 +619,7 @@
  	running = mt7915_dev_running(dev);
  
  	if (!running) {
-@@ -95,6 +93,18 @@ out:
+@@ -85,6 +83,18 @@ out:
  	return ret;
  }
  
@@ -638,7 +639,7 @@
  {
  	struct mt7915_dev *dev = mt7915_hw_dev(hw);
 diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index 987e5f3f..e7c0ab1d 100644
+index 681ede23..2128e4ca 100755
 --- a/mt7915/mcu.c
 +++ b/mt7915/mcu.c
 @@ -212,14 +212,31 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
@@ -719,7 +720,7 @@
  
  	ret = mt7915_driver_own(dev, 0);
  	if (ret)
-@@ -2532,6 +2544,20 @@ int mt7915_mcu_init(struct mt7915_dev *dev)
+@@ -2535,6 +2547,20 @@ int mt7915_mcu_init(struct mt7915_dev *dev)
  				 MCU_WA_PARAM_RED, 0, 0);
  }
  
@@ -741,7 +742,7 @@
  {
  	__mt76_mcu_restart(&dev->mt76);
 diff --git a/mt7915/mmio.c b/mt7915/mmio.c
-index 2466907e..561ac650 100644
+index 0bd32daa..f07b0565 100644
 --- a/mt7915/mmio.c
 +++ b/mt7915/mmio.c
 @@ -22,6 +22,8 @@ static const u32 mt7915_reg[] = {
@@ -771,7 +772,7 @@
  };
  
  static const u32 mt7915_offs[] = {
-@@ -601,10 +607,10 @@ static void mt7915_irq_tasklet(struct tasklet_struct *t)
+@@ -607,10 +613,10 @@ static void mt7915_irq_tasklet(struct tasklet_struct *t)
  		u32 val = mt76_rr(dev, MT_MCU_CMD);
  
  		mt76_wr(dev, MT_MCU_CMD, val);
@@ -786,7 +787,7 @@
  	}
  }
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index b4d3981e..87557da8 100644
+index 24276da5..abd8d8c3 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -343,6 +343,15 @@ struct mt7915_dev {
@@ -819,7 +820,7 @@
  static inline struct mt7915_phy *
  mt7915_hw_phy(struct ieee80211_hw *hw)
  {
-@@ -656,6 +672,17 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy, void *ms);
+@@ -658,6 +674,17 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy, void *ms);
  int mt7915_init_debugfs(struct mt7915_phy *phy);
  void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int len);
  bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len);
@@ -838,7 +839,7 @@
  void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  			    struct ieee80211_sta *sta, struct dentry *dir);
 diff --git a/mt7915/regs.h b/mt7915/regs.h
-index 6ddfa48f..27f682fe 100644
+index 97984aaf..a2697e92 100644
 --- a/mt7915/regs.h
 +++ b/mt7915/regs.h
 @@ -30,6 +30,8 @@ enum reg_rev {
@@ -873,7 +874,7 @@
  /* WFDMA1 */
  #define MT_WFDMA1_BASE			0xd5000
  #define MT_WFDMA1(ofs)			(MT_WFDMA1_BASE + (ofs))
-@@ -687,6 +698,12 @@ enum offs_rev {
+@@ -700,6 +711,12 @@ enum offs_rev {
  #define MT_MCU_CMD_NORMAL_STATE		BIT(5)
  #define MT_MCU_CMD_ERROR_MASK		GENMASK(5, 1)
  
@@ -886,7 +887,7 @@
  /* TOP RGU */
  #define MT_TOP_RGU_BASE			0x18000000
  #define MT_TOP_PWR_CTRL			(MT_TOP_RGU_BASE + (0x0))
-@@ -929,12 +946,25 @@ enum offs_rev {
+@@ -942,12 +959,25 @@ enum offs_rev {
  #define MT_ADIE_TYPE_MASK		BIT(1)
  
  /* FW MODE SYNC */
@@ -914,7 +915,7 @@
  #define MT_DIC_CMD_REG_BASE		0x41f000
  #define MT_DIC_CMD_REG(ofs)		(MT_DIC_CMD_REG_BASE + (ofs))
  #define MT_DIC_CMD_REG_CMD		MT_DIC_CMD_REG(0x10)
-@@ -1016,6 +1046,9 @@ enum offs_rev {
+@@ -1029,6 +1059,9 @@ enum offs_rev {
  
  #define MT_MCU_BUS_REMAP		MT_MCU_BUS(0x120)
  
diff --git a/recipes-kernel/linux-mt76/files/patches/3001-mt76-mt7915-init-rssi-in-WTBL-when-add-station.patch b/recipes-kernel/linux-mt76/files/patches/3001-mt76-mt7915-init-rssi-in-WTBL-when-add-station.patch
new file mode 100644
index 0000000..22ae63b
--- /dev/null
+++ b/recipes-kernel/linux-mt76/files/patches/3001-mt76-mt7915-init-rssi-in-WTBL-when-add-station.patch
@@ -0,0 +1,34 @@
+From 04ef8f969aa6a51dd6d9ccd2723513bed3a588a0 Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Sun, 24 Apr 2022 10:07:00 +0800
+Subject: [PATCH] mt76: mt7915: init rssi in WTBL when add station
+
+---
+ mt7915/main.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/mt7915/main.c b/mt7915/main.c
+index 09659dc7..3c6c66b8 100644
+--- a/mt7915/main.c
++++ b/mt7915/main.c
+@@ -671,6 +671,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ 	struct mt7915_phy *phy;
+ #endif
+ 	int ret, idx;
++	u32 addr;
+ 
+ 	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
+ 	if (idx < 0)
+@@ -692,6 +693,9 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ 	if (ret)
+ 		return ret;
+ 
++	addr = mt7915_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 30);
++	mt76_rmw_field(dev, addr, GENMASK(7, 0), 0xa0);
++
+ #ifdef CONFIG_MTK_VENDOR
+ 	mt7915_vendor_amnt_sta_remove(mvif->phy, sta);
+ #endif
+-- 
+2.18.0
+
diff --git a/recipes-kernel/linux-mt76/files/patches/patches.inc b/recipes-kernel/linux-mt76/files/patches/patches.inc
index 63fe86c..b331b64 100644
--- a/recipes-kernel/linux-mt76/files/patches/patches.inc
+++ b/recipes-kernel/linux-mt76/files/patches/patches.inc
@@ -5,11 +5,8 @@
     file://0003-mt76-mt7915-rework-rx-testmode-stats.patch \
     file://0004-mt76-mt7915-fix-tx-descriptor.patch \
     file://0007-mt76-mt7915-update-mt7986-CR-for-different-adie-vers.patch \
-    file://0008-mt76-mt7915-disable-mt7986-rx-hdr-trans-short.patch \
     file://0009-mt76-mt7915-fix-table_mask-to-u16.patch \
-    file://0011-mt76-mt7915-add-list_del_init-msta-wcid.list.patch \
     file://0012-mt76-mt7915-reject-duplicated-twt-flow.patch \
-    file://0013-mt76-mt7915-report-qos_ctl-without-ACK-policy-to-the.patch \
     file://100-Revert-of-net-pass-the-dst-buffer-to-of_get_mac_addr.patch \
     file://1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch \
     file://1002-mt76-mt7915-csi-implement-csi-support.patch \
@@ -30,4 +27,5 @@
     file://1111-mt76-tool-add-more-commands.patch \
     file://1112-mt76-mt7915-add-L0.5-SER-for-mt7986.patch \
     file://3000-mt76-remove-WED-support-patch-for-build-err.patch \
+    file://3001-mt76-mt7915-init-rssi-in-WTBL-when-add-station.patch \
     "