[rdk-b][common][bsp][Refactor and sync kernel/wifi from Openwrt]

[Description]
Refactor and sync kernel/wifi from Openwrt,Add HW QoS/PPPQ support

[Release-log]
N/A

diff --git a/recipes-kernel/linux-mt76/files/patches/3001-mt76-add-wed-tx-support.patch b/recipes-kernel/linux-mt76/files/patches/3001-mt76-add-wed-tx-support.patch
index b5b407c..6e4f96e 100644
--- a/recipes-kernel/linux-mt76/files/patches/3001-mt76-add-wed-tx-support.patch
+++ b/recipes-kernel/linux-mt76/files/patches/3001-mt76-add-wed-tx-support.patch
@@ -7,7 +7,7 @@
 ---
  mt76_connac.h   |   1 +
  mt7915/dma.c    |  59 +++++++++++++++++++-------
- mt7915/mac.c    |   4 +-
+ mt7915/mac.c    |  11 +++--
  mt7915/main.c   |   9 +++-
  mt7915/mcu.c    |   2 +-
  mt7915/mmio.c   | 110 +++++++++++++++++++++++++++++++++++++++++++++++-
@@ -159,6 +159,31 @@
  }
  
  static void
+@@ -944,6 +944,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
+ 	LIST_HEAD(free_list);
+ 	void *end = data + len;
+ 	bool v3, wake = false;
++	bool with_txwi = true;
+ 	u16 total, count = 0;
+ 	u32 txd = le32_to_cpu(free->txd);
+ 	__le32 *cur_info;
+@@ -997,12 +998,14 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
+ 			txwi = mt76_token_release(mdev, msdu, &wake);
+ 			if (!txwi)
+ 				continue;
++			else
++				with_txwi = false;
+
+ 			mt7915_txwi_free(dev, txwi, sta, &free_list);
+ 		}
+ 	}
+-
+-	mt7915_mac_tx_free_done(dev, &free_list, wake);
++	if (!with_txwi)
++		mt7915_mac_tx_free_done(dev, &free_list, wake);
+ }
+
+ static void
 diff --git a/mt7915/main.c b/mt7915/main.c
 index 192b0a9b..3a09f3f5 100644
 --- a/mt7915/main.c
diff --git a/recipes-kernel/linux-mt76/files/patches/3003-mt76-add-wed-rx-support.patch b/recipes-kernel/linux-mt76/files/patches/3003-mt76-add-wed-rx-support.patch
index d07d072..4646c44 100644
--- a/recipes-kernel/linux-mt76/files/patches/3003-mt76-add-wed-rx-support.patch
+++ b/recipes-kernel/linux-mt76/files/patches/3003-mt76-add-wed-rx-support.patch
@@ -758,7 +758,17 @@
 index ac30698f..197a0169 100644
 --- a/mt7915/dma.c
 +++ b/mt7915/dma.c
-@@ -349,6 +349,7 @@ static int mt7915_dma_enable(struct mt7915_dev *dev)
+@@ -337,7 +337,8 @@ static int mt7915_dma_enable(struct mt7915_dev *dev)
+ 		wed_irq_mask |= MT_INT_TX_DONE_BAND0 | MT_INT_TX_DONE_BAND1;
+ 		if (!is_mt7986(&dev->mt76))
+ 			mt76_wr(dev, MT_INT_WED_MASK_CSR, wed_irq_mask);
+-		mt76_wr(dev, MT_INT_MASK_CSR, wed_irq_mask);
++		else
++			mt76_wr(dev, MT_INT_MASK_CSR, wed_irq_mask);
+ 		mtk_wed_device_start(&dev->mt76.mmio.wed, wed_irq_mask);
+ 	}
+
+@@ -349,6 +350,7 @@ static int mt7915_dma_enable(struct mt7915_dev *dev)
  int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
  {
  	struct mt76_dev *mdev = &dev->mt76;
@@ -1127,7 +1137,7 @@
  
  #define MT_WFDMA0_MCU_HOST_INT_ENA	MT_WFDMA0(0x1f4)
  #define MT_WFDMA0_MT_WA_WDT_INT		BIT(31)
-@@ -668,12 +675,15 @@ enum offs_rev {
+@@ -668,12 +675,18 @@ enum offs_rev {
  #define MT_TXQ_EXT_CTRL(q)		(MT_Q_BASE(__TXQ(q)) + 0x600 +	\
  					 MT_TXQ_ID(q)* 0x4)
  
@@ -1139,9 +1149,13 @@
  
  #define MT_WED_TX_DONE_BAND0		(is_mt7915(mdev)? 4 : 30)
  #define MT_WED_TX_DONE_BAND1		(is_mt7915(mdev)? 5 : 31)
- #define MT_WED_TX_FREE_DONE		(is_mt7915(mdev)? 1 : 2)
-+#define MT_WED_RX_DONE_BAND0		(is_mt7915(mdev)? 16 : 22)
-+#define MT_WED_RX_DONE_BAND1		(is_mt7915(mdev)? 17 : 23)
+-#define MT_WED_TX_FREE_DONE		(is_mt7915(mdev)? 1 : 2)
++#define MT_WED_TX_FREE_DONE		(is_mt7986(mdev) ? 2 : 1)
++#define MT_WED_RX_DONE_BAND0		(is_mt7915(mdev) ? 16 : \
++					 (is_mt7986(mdev) ? 22 : 18))
++#define MT_WED_RX_DONE_BAND1		(is_mt7915(mdev) ? 17 : \
++					 (is_mt7986(mdev) ? 23 : 19))
++
  
  #define MT_INT_SOURCE_CSR		__REG(INT_SOURCE_CSR)
  #define MT_INT_MASK_CSR			__REG(INT_MASK_CSR)
diff --git a/recipes-kernel/linux-mt76/files/patches/3009-mt76-mt7915-find-rx-token-by-physical-address.patch b/recipes-kernel/linux-mt76/files/patches/3009-mt76-mt7915-find-rx-token-by-physical-address.patch
new file mode 100644
index 0000000..8e1873d
--- /dev/null
+++ b/recipes-kernel/linux-mt76/files/patches/3009-mt76-mt7915-find-rx-token-by-physical-address.patch
@@ -0,0 +1,50 @@
+From c72a8943ae9e7b97d9f67c066fe232eba920f517 Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Tue, 27 Sep 2022 16:34:26 +0800
+Subject: [PATCH 3009/3010] mt76: mt7915: find rx token by physical address
+
+The token id in RxDMAD may be incorrect when it is not the last frame due to
+WED HW bug. Lookup correct token id by physical address in sdp0.
+
+Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
+---
+ dma.c | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/dma.c b/dma.c
+index fa56ccfb..c5513690 100644
+--- a/dma.c
++++ b/dma.c
+@@ -380,11 +380,28 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx,
+
+ 	type = FIELD_GET(MT_QFLAG_WED_TYPE, q->flags);
+ 	if (mtk_wed_device_active(wed) && type == MT76_WED_Q_RX) {
+-		u32 token;
++		u32 token, id, find = 0;
+ 		struct mt76_txwi_cache *r;
+
+ 		token = FIELD_GET(MT_DMA_CTL_TOKEN, desc->buf1);
+
++		if (*more) {
++			spin_lock_bh(&dev->rx_token_lock);
++
++			idr_for_each_entry(&dev->rx_token, r, id) {
++				if (r->dma_addr == le32_to_cpu(desc->buf0)) {
++					find = 1;
++					desc->buf1 = FIELD_PREP(MT_DMA_CTL_TOKEN, id);
++					token = id;
++					break;
++				}
++			}
++
++			spin_unlock_bh(&dev->rx_token_lock);
++			if (!find)
++				return NULL;
++
++		}
+ 		r = mt76_rx_token_release(dev, token);
+ 		if (!r)
+ 			return NULL;
+--
+2.18.0
+
diff --git a/recipes-kernel/linux-mt76/files/patches/patches.inc b/recipes-kernel/linux-mt76/files/patches/patches.inc
index 98709a2..eb2119c 100644
--- a/recipes-kernel/linux-mt76/files/patches/patches.inc
+++ b/recipes-kernel/linux-mt76/files/patches/patches.inc
@@ -40,4 +40,5 @@
     file://3006-mt76-mt7915-add-statistic-for-H-W-Rx-Path.patch \
     file://3007-mt76-mt7915-enable-red-per-band-token-drop-for-HW-Pa.patch \
     file://3008-mt76-mt7915-update-mt7916-trinfo-when-hw-path-enable.patch \
+    file://3009-mt76-mt7915-find-rx-token-by-physical-address.patch \
     "