[][MT76][WED][re-patch wed patches]

[Description]
Change wds patch to tx patch from rx patch

Fix wed wds wcid clear fail issue by check wed_wds

[Release-log]
N/A

Change-Id: I1bab0dd2d0822e186c38dd2210f9a1713a16da35
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6498928
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/3002-mt76-add-wed-rx-support.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/3002-mt76-add-wed-rx-support.patch
index 499e4c6..4b7c349 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/3002-mt76-add-wed-rx-support.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/3002-mt76-add-wed-rx-support.patch
@@ -8,7 +8,7 @@
  dma.c             | 250 ++++++++++++++++++++++++++++++++++++++--------
  dma.h             |  10 ++
  mac80211.c        |   8 +-
- mt76.h            |  25 ++++-
+ mt76.h            |  24 ++++-
  mt7603/dma.c      |   2 +-
  mt7603/mt7603.h   |   2 +-
  mt7615/mac.c      |   2 +-
@@ -17,19 +17,16 @@
  mt76x02.h         |   2 +-
  mt76x02_txrx.c    |   2 +-
  mt7915/dma.c      |  25 +++--
- mt7915/init.c     |   9 ++
  mt7915/mac.c      | 103 ++++++++++++++++++-
- mt7915/main.c     |  26 ++++-
- mt7915/mcu.c      |  14 ++-
- mt7915/mcu.h      |   1 +
+ mt7915/mcu.c      |   3 +
  mt7915/mmio.c     |  26 ++++-
- mt7915/mt7915.h   |  10 +-
+ mt7915/mt7915.h   |   7 +-
  mt7915/regs.h     |  14 ++-
  mt7921/mac.c      |   2 +-
  mt7921/mt7921.h   |   4 +-
  mt7921/pci_mac.c  |   4 +-
  tx.c              |  34 +++++++
- 24 files changed, 505 insertions(+), 81 deletions(-)
+ 21 files changed, 460 insertions(+), 75 deletions(-)
 
 diff --git a/dma.c b/dma.c
 index 8ea09e6..3317d2b 100644
@@ -504,10 +501,10 @@
  #define MT_RX_INFO_LEN			4
  #define MT_FCE_INFO_LEN			4
 diff --git a/mac80211.c b/mac80211.c
-index 2f0605d..a2bd8ca 100644
+index 4eaf317..731b78f 100644
 --- a/mac80211.c
 +++ b/mac80211.c
-@@ -598,11 +598,14 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
+@@ -599,11 +599,14 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
  		BIT(NL80211_IFTYPE_ADHOC);
  
  	spin_lock_init(&dev->token_lock);
@@ -522,7 +519,7 @@
  	dev->token_size = dev->drv->token_size;
  
  	for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++)
-@@ -1300,7 +1303,10 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
+@@ -1301,7 +1304,10 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
  
  	while ((skb = __skb_dequeue(&dev->rx_skb[q])) != NULL) {
  		mt76_check_sta(dev, skb);
@@ -535,7 +532,7 @@
  
  	mt76_rx_complete(dev, &frames, napi);
 diff --git a/mt76.h b/mt76.h
-index 4a41949..fb3ae86 100644
+index b7da992..20fd0ec 100644
 --- a/mt76.h
 +++ b/mt76.h
 @@ -20,6 +20,8 @@
@@ -584,7 +581,7 @@
  
  	void (*rx_poll_complete)(struct mt76_dev *dev, enum mt76_rxq_id q);
  
-@@ -756,6 +763,7 @@ struct mt76_dev {
+@@ -757,6 +764,7 @@ struct mt76_dev {
  	struct ieee80211_hw *hw;
  
  	spinlock_t lock;
@@ -592,7 +589,7 @@
  	spinlock_t cc_lock;
  
  	u32 cur_cc_bss_rx;
-@@ -781,6 +789,7 @@ struct mt76_dev {
+@@ -782,6 +790,7 @@ struct mt76_dev {
  	struct sk_buff_head rx_skb[__MT_RXQ_MAX];
  
  	struct list_head txwi_cache;
@@ -600,7 +597,7 @@
  	struct mt76_queue *q_mcu[__MT_MCUQ_MAX];
  	struct mt76_queue q_rx[__MT_RXQ_MAX];
  	const struct mt76_queue_ops *queue_ops;
-@@ -794,12 +803,16 @@ struct mt76_dev {
+@@ -795,6 +804,9 @@ struct mt76_dev {
  	u16 wed_token_count;
  	u16 token_count;
  	u16 token_size;
@@ -610,14 +607,7 @@
  
  	wait_queue_head_t tx_wait;
  	/* spinclock used to protect wcid pktid linked list */
- 	spinlock_t status_lock;
- 
- 	u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
-+	u32 wcid_wds_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
- 	u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
- 
- 	u64 vif_mask;
-@@ -1357,6 +1370,8 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb)
+@@ -1359,6 +1371,8 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb)
  }
  
  void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t);
@@ -626,7 +616,7 @@
  void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
  		      struct napi_struct *napi);
  void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
-@@ -1501,6 +1516,12 @@ struct mt76_txwi_cache *
+@@ -1503,6 +1517,12 @@ struct mt76_txwi_cache *
  mt76_token_release(struct mt76_dev *dev, int token, bool *wake);
  int mt76_token_consume(struct mt76_dev *dev, struct mt76_txwi_cache **ptxwi);
  void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked);
@@ -836,26 +826,6 @@
  		/* rx data queue for band1 */
  		ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_BAND1],
  				       MT_RXQ_ID(MT_RXQ_BAND1),
-diff --git a/mt7915/init.c b/mt7915/init.c
-index 538ff5c..cd9d846 100644
---- a/mt7915/init.c
-+++ b/mt7915/init.c
-@@ -695,6 +695,15 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2)
- 			return ret;
- 	}
- 
-+	/* wds workaround for mt7986 */
-+	if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7986(&dev->mt76)) {
-+		for(idx = MT7915_WTBL_WDS_START; idx < MT7915_WTBL_WDS_END; idx++)
-+			mt76_wcid_mask_set(dev->mt76.wcid_mask, idx);
-+
-+		for (idx = 0; idx < DIV_ROUND_UP(MT7915_WTBL_STA, 32); idx++)
-+			dev->mt76.wcid_wds_mask[idx] = ~dev->mt76.wcid_mask[idx];
-+	}
-+
- 	/* Beacon and mgmt frames should occupy wcid 0 */
- 	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
- 	if (idx)
 diff --git a/mt7915/mac.c b/mt7915/mac.c
 index 0a13b7d..4e1dfc9 100644
 --- a/mt7915/mac.c
@@ -1005,60 +975,8 @@
  			mt76_rx(&dev->mt76, q, skb);
  			return;
  		}
-diff --git a/mt7915/main.c b/mt7915/main.c
-index b77b3be..29ee700 100644
---- a/mt7915/main.c
-+++ b/mt7915/main.c
-@@ -670,8 +670,15 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
- #endif
- 	int ret, idx;
- 	u32 addr;
-+	bool wed_wds = false;
- 
--	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
-+	if (mtk_wed_device_active(&mdev->mmio.wed) && is_mt7986(mdev))
-+		wed_wds = !!test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
-+
-+	if (wed_wds)
-+		idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA);
-+	else
-+	        idx = mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA);
- 	if (idx < 0)
- 		return -ENOSPC;
- 
-@@ -1107,6 +1114,14 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
- 	else
- 		clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
- 
-+	if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
-+	    is_mt7986(&dev->mt76) &&
-+	    (msta->wcid.idx < MT7915_WTBL_WDS_START ||
-+	     msta->wcid.idx > MT7915_WTBL_WDS_END)) {
-+		mt7915_sta_remove(hw, vif, sta);
-+		mt7915_sta_add(hw, vif, sta);
-+	 }
-+
- 	mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
- }
- 
-@@ -1449,9 +1464,12 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
- 	/* fw will find the wcid by dest addr */
- 	if(is_mt7915(&dev->mt76))
- 		path->mtk_wdma.wcid = 0xff;
--	else
--		path->mtk_wdma.wcid = 0x3ff;
--
-+	else {
-+		if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags))
-+			path->mtk_wdma.wcid = msta->wcid.idx;
-+		else
-+			path->mtk_wdma.wcid = 0x3ff;
-+	}
- 	path->mtk_wdma.queue = phy != &dev->phy;
- 
- 	ctx->dev = NULL;
 diff --git a/mt7915/mcu.c b/mt7915/mcu.c
-index a041bb2..3d50b78 100644
+index 73efa55..22f68da 100644
 --- a/mt7915/mcu.c
 +++ b/mt7915/mcu.c
 @@ -1722,6 +1722,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
@@ -1078,43 +996,6 @@
  	return mt76_mcu_skb_send_msg(&dev->mt76, skb,
  				     MCU_EXT_CMD(STA_REC_UPDATE), true);
  }
-@@ -2348,6 +2351,7 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
- int mt7915_run_firmware(struct mt7915_dev *dev)
- {
- 	int ret;
-+	struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
- 
- 	/* force firmware operation mode into normal state,
- 	 * which should be set before firmware download stage.
-@@ -2377,8 +2381,14 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
- 	if (ret)
- 		return ret;
- 
--	if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76))
--		mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0);
-+	if (mtk_wed_device_active(wed)) {
-+		if (is_mt7915(&dev->mt76))
-+			mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY),
-+					  0, 0, 0);
-+		mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
-+				  MCU_WA_PARAM_WED_VERSION,
-+				  wed->rev_id, 0);
-+	}
- 
- 	ret = mt7915_mcu_set_mwds(dev, 1);
- 	if (ret)
-diff --git a/mt7915/mcu.h b/mt7915/mcu.h
-index 9d0fac4..1f56db6 100644
---- a/mt7915/mcu.h
-+++ b/mt7915/mcu.h
-@@ -268,6 +268,7 @@ enum {
- 	MCU_WA_PARAM_RED_SHOW_STA = 0xf,
- 	MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
- #endif
-+	MCU_WA_PARAM_WED_VERSION = 0x32,
- };
- 
- enum mcu_mmps_mode {
 diff --git a/mt7915/mmio.c b/mt7915/mmio.c
 index b0d8a61..111444d 100644
 --- a/mt7915/mmio.c
@@ -1197,20 +1078,10 @@
  	dev->mt76.dma_dev = wed->dev;
  	mdev->token_size = wed->wlan.token_start;
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index e329f74..b10b90a 100644
+index 33c00af..b805aae 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
-@@ -18,6 +18,9 @@
- #define MT7915_WTBL_STA			(MT7915_WTBL_RESERVED - \
- 					 MT7915_MAX_INTERFACES)
- 
-+#define MT7915_WTBL_WDS_START		256
-+#define MT7915_WTBL_WDS_END		274
-+
- #define MT7915_WATCHDOG_TIME		(HZ / 10)
- #define MT7915_RESET_TIMEOUT		(30 * HZ)
- 
-@@ -78,6 +81,7 @@
+@@ -81,6 +81,7 @@
  #define MT7915_MAX_STA_TWT_AGRT		8
  #define MT7915_MIN_TWT_DUR 64
  #define MT7915_MAX_QUEUE		(MT_RXQ_BAND2 + __MT_MCUQ_MAX + 2)
@@ -1218,7 +1089,7 @@
  
  struct mt7915_vif;
  struct mt7915_sta;
-@@ -544,7 +548,9 @@ void mt7915_wfsys_reset(struct mt7915_dev *dev);
+@@ -547,7 +548,9 @@ void mt7915_wfsys_reset(struct mt7915_dev *dev);
  irqreturn_t mt7915_irq_handler(int irq, void *dev_instance);
  u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif);
  u32 mt7915_wed_init_buf(void *ptr, dma_addr_t phys, int token_id);
@@ -1229,15 +1100,15 @@
  int mt7915_register_device(struct mt7915_dev *dev);
  void mt7915_unregister_device(struct mt7915_dev *dev);
  int mt7915_eeprom_init(struct mt7915_dev *dev);
-@@ -697,7 +703,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
+@@ -700,7 +703,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
  			  struct mt76_tx_info *tx_info);
  void mt7915_tx_token_put(struct mt7915_dev *dev);
  void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 -			 struct sk_buff *skb);
 +			 struct sk_buff *skb, u32 info);
  bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len);
+ bool mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta);
  void mt7915_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps);
- void mt7915_stats_work(struct work_struct *work);
 diff --git a/mt7915/regs.h b/mt7915/regs.h
 index 432ed30..36ef8a9 100644
 --- a/mt7915/regs.h