[Refactor and sync wifi from Openwrt]

[Description]
Refactor and sync wifi from Openwrt

[Release-log]
N/A

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
index 77cbc39..5fe3710 100644
--- 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,31 +1,32 @@
-From a9cf0fd711fdccf35e6171dd4aba0eb7f6588148 Mon Sep 17 00:00:00 2001
-From: Bo Jiao <Bo.Jiao@mediatek.com>
-Date: Mon, 6 Jun 2022 20:08:58 +0800
-Subject: [PATCH] mt76: mt7915: add mtk internal debug tools for mt76
+From 4c1658312392db894fd36bbdc98476d6e6b1e32f Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Wed, 22 Jun 2022 10:39:47 +0800
+Subject: [PATCH 1001/1008] mt76: mt7915: add mtk internal debug tools for mt76
 
 ---
  mt76_connac_mcu.h     |    6 +
  mt7915/Makefile       |    2 +-
  mt7915/debugfs.c      |   73 +-
  mt7915/mac.c          |   14 +
- mt7915/mcu.c          |   41 +
+ mt7915/main.c         |    4 +
+ mt7915/mcu.c          |   44 +
  mt7915/mcu.h          |    4 +
- mt7915/mt7915.h       |   41 +
+ mt7915/mt7915.h       |   43 +
  mt7915/mt7915_debug.h | 1350 +++++++++++++++++++
- mt7915/mtk_debugfs.c  | 2921 +++++++++++++++++++++++++++++++++++++++++
+ mt7915/mtk_debugfs.c  | 2923 +++++++++++++++++++++++++++++++++++++++++
  mt7915/mtk_mcu.c      |   51 +
  tools/fwlog.c         |   44 +-
- 11 files changed, 4534 insertions(+), 13 deletions(-)
+ 12 files changed, 4545 insertions(+), 13 deletions(-)
  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 aa14d2d4..03134066 100644
+index e94d670..333d3a0 100644
 --- a/mt76_connac_mcu.h
 +++ b/mt76_connac_mcu.h
-@@ -968,6 +968,12 @@ enum {
+@@ -1119,6 +1119,12 @@ enum {
  	MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
  	MCU_EXT_CMD_RXDCOC_CAL = 0x59,
  	MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
@@ -39,7 +40,7 @@
  	MCU_EXT_CMD_CAL_CACHE = 0x67,
  	MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
 diff --git a/mt7915/Makefile b/mt7915/Makefile
-index b794ceb7..a3474e2f 100644
+index b794ceb..a3474e2 100644
 --- a/mt7915/Makefile
 +++ b/mt7915/Makefile
 @@ -3,7 +3,7 @@
@@ -53,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 9f21d978..0cfb6068 100644
+index 9f21d97..0cfb606 100644
 --- a/mt7915/debugfs.c
 +++ b/mt7915/debugfs.c
 @@ -8,6 +8,9 @@
@@ -197,10 +198,10 @@
  
  	if (dev->relay_fwlog)
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index b0e86968..9e92b32f 100644
+index 6a4da8e..c332e0a 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
-@@ -596,6 +596,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -239,6 +239,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
  	__le16 fc = 0;
  	int idx;
  
@@ -211,7 +212,7 @@
  	memset(status, 0, sizeof(*status));
  
  	if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->band_idx) {
-@@ -780,6 +784,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
+@@ -421,6 +425,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
  	}
  
  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
@@ -220,9 +221,9 @@
 +		mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX, hdr_gap);
 +#endif
  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
- 		if (mt7915_reverse_frag0_hdr_trans(skb, hdr_gap))
- 			return -EINVAL;
-@@ -1358,6 +1366,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
+ 		struct ieee80211_vif *vif;
+ 		int err;
+@@ -760,6 +768,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;
  
@@ -235,24 +236,50 @@
  	return 0;
  }
  
+diff --git a/mt7915/main.c b/mt7915/main.c
+index 3958799..929c726 100644
+--- a/mt7915/main.c
++++ b/mt7915/main.c
+@@ -62,7 +62,11 @@ static int mt7915_start(struct ieee80211_hw *hw)
+ 	if (ret)
+ 		goto out;
+ 
++#ifdef MTK_DEBUG
++	ret = mt7915_mcu_set_sku_en(phy, !dev->dbg.sku_disable);
++#else
+ 	ret = mt7915_mcu_set_sku_en(phy, true);
++#endif
+ 	if (ret)
+ 		goto out;
+ 
 diff --git a/mt7915/mcu.c b/mt7915/mcu.c
 old mode 100644
 new mode 100755
-index 81559002..6ec321e1
+index a726021..4ff13c7
 --- a/mt7915/mcu.c
 +++ b/mt7915/mcu.c
-@@ -298,6 +298,10 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
- 		mcu_txd->s2d_index = MCU_S2D_H2N;
+@@ -195,6 +195,11 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
+ 	else
+ 		qid = MT_MCUQ_WM;
  
- exit:
 +#ifdef MTK_DEBUG
 +	if (dev->dbg.dump_mcu_pkt)
 +		mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_MCU, 0);
 +#endif
- 	if (wait_seq)
- 		*wait_seq = seq;
++
+ 	return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0);
+ }
+ 
+@@ -3164,6 +3169,8 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
+ 		.sku_enable = enable,
+ 	};
  
-@@ -3733,6 +3737,43 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
++	pr_info("%s: enable = %d\n", __func__, enable);
++
+ 	return mt76_mcu_send_msg(&dev->mt76,
+ 				 MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
+ 				 sizeof(req), true);
+@@ -3439,6 +3446,43 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
  				 &req, sizeof(req), true);
  }
  
@@ -297,10 +324,10 @@
  {
  	struct {
 diff --git a/mt7915/mcu.h b/mt7915/mcu.h
-index d46c8da4..2f7007fd 100644
+index b82f258..b2c51bf 100644
 --- a/mt7915/mcu.h
 +++ b/mt7915/mcu.h
-@@ -296,6 +296,10 @@ enum {
+@@ -259,6 +259,10 @@ enum {
  	MCU_WA_PARAM_PDMA_RX = 0x04,
  	MCU_WA_PARAM_CPU_UTIL = 0x0b,
  	MCU_WA_PARAM_RED = 0x0e,
@@ -312,7 +339,7 @@
  
  enum mcu_mmps_mode {
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index bd985e6c..001a6015 100644
+index b6a6aa7..594f2fb 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -9,6 +9,7 @@
@@ -321,9 +348,9 @@
  
 +#define MTK_DEBUG 1
  #define MT7915_MAX_INTERFACES		19
- #define MT7915_MAX_WMM_SETS		4
  #define MT7915_WTBL_SIZE		288
-@@ -339,6 +340,27 @@ struct mt7915_dev {
+ #define MT7916_WTBL_SIZE		544
+@@ -338,6 +339,29 @@ struct mt7915_dev {
  	struct reset_control *rstc;
  	void __iomem *dcm;
  	void __iomem *sku;
@@ -345,13 +372,15 @@
 +		bool dump_rx_pkt;
 +		bool dump_rx_raw;
 +		u32 token_idx;
++		u8 sku_disable;
++		u8 muru_onoff;
 +	} dbg;
 +	const struct mt7915_dbg_reg_desc *dbg_reg;
 +#endif
  };
  
  enum {
-@@ -608,4 +630,23 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+@@ -592,4 +616,23 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  			    struct ieee80211_sta *sta, struct dentry *dir);
  #endif
  
@@ -377,7 +406,7 @@
  #endif
 diff --git a/mt7915/mt7915_debug.h b/mt7915/mt7915_debug.h
 new file mode 100644
-index 00000000..58ba2cdf
+index 0000000..58ba2cd
 --- /dev/null
 +++ b/mt7915/mt7915_debug.h
 @@ -0,0 +1,1350 @@
@@ -1733,10 +1762,10 @@
 +#endif
 diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
 new file mode 100644
-index 00000000..ccaaea78
+index 0000000..f18c8b6
 --- /dev/null
 +++ b/mt7915/mtk_debugfs.c
-@@ -0,0 +1,2921 @@
+@@ -0,0 +1,2923 @@
 +#include<linux/inet.h>
 +#include "mt7915.h"
 +#include "mt7915_debug.h"
@@ -4655,12 +4684,14 @@
 +	debugfs_create_file("txpower_level", 0400, dir, dev,
 +			    &fops_txpower_level);
 +
++	debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable);
++
 +	return 0;
 +}
 +#endif
 diff --git a/mt7915/mtk_mcu.c b/mt7915/mtk_mcu.c
 new file mode 100644
-index 00000000..145fe785
+index 0000000..145fe78
 --- /dev/null
 +++ b/mt7915/mtk_mcu.c
 @@ -0,0 +1,51 @@
@@ -4716,7 +4747,7 @@
 +				 sizeof(req), true);
 +}
 diff --git a/tools/fwlog.c b/tools/fwlog.c
-index e5d4a105..3d51d9ec 100644
+index e5d4a10..3d51d9e 100644
 --- a/tools/fwlog.c
 +++ b/tools/fwlog.c
 @@ -26,7 +26,7 @@ static const char *debugfs_path(const char *phyname, const char *file)