[][MAC80211][mt76][rework patches for mt7996]

[Description]
Refactor patches of mt7996 autobuild on top of mt76 master.

[Release-log]
N/A

Change-Id: If9caf30404c61e4f294e2f3ebe6325659ed35384
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7097840
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-Revert-wifi-mt76-mt7996-rely-on-mt76_connac_tx_compl.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-Revert-wifi-mt76-mt7996-rely-on-mt76_connac_tx_compl.patch
new file mode 100644
index 0000000..1022535
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/kernel/mt76/patches/0001-Revert-wifi-mt76-mt7996-rely-on-mt76_connac_tx_compl.patch
@@ -0,0 +1,96 @@
+From 6767bcfec5f48f14fdf63c9699c63e6bc741ad74 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Fri, 3 Feb 2023 11:00:59 +0800
+Subject: [PATCH 1/7] Revert "wifi: mt76: mt7996: rely on
+ mt76_connac_tx_complete_skb"
+
+This reverts commit 8688756305c643b8a296c16d0626732aaae1d02a.
+---
+ mt7996/mac.c    | 21 +++++++++++++++++++++
+ mt7996/mac.h    | 13 +++++++++++++
+ mt7996/mmio.c   |  2 +-
+ mt7996/mt7996.h |  1 +
+ 4 files changed, 36 insertions(+), 1 deletion(-)
+
+diff --git a/mt7996/mac.c b/mt7996/mac.c
+index c9a9f0e3..0d718598 100644
+--- a/mt7996/mac.c
++++ b/mt7996/mac.c
+@@ -1565,6 +1565,27 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
+ 	}
+ }
+ 
++void mt7996_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)
++{
++	if (!e->txwi) {
++		dev_kfree_skb_any(e->skb);
++		return;
++	}
++
++	/* error path */
++	if (e->skb == DMA_DUMMY_DATA) {
++		struct mt76_connac_txp_common *txp;
++		struct mt76_txwi_cache *t;
++
++		txp = mt7996_txwi_to_txp(mdev, e->txwi);
++		t = mt76_token_put(mdev, le16_to_cpu(txp->fw.token));
++		e->skb = t ? t->skb : NULL;
++	}
++
++	if (e->skb)
++		mt76_tx_complete_skb(mdev, e->wcid, e->skb);
++}
++
+ void mt7996_mac_cca_stats_reset(struct mt7996_phy *phy)
+ {
+ 	struct mt7996_dev *dev = phy->dev;
+diff --git a/mt7996/mac.h b/mt7996/mac.h
+index 27184cba..10e08d66 100644
+--- a/mt7996/mac.h
++++ b/mt7996/mac.h
+@@ -371,4 +371,17 @@ struct mt7996_dfs_radar_spec {
+ 	struct mt7996_dfs_pattern radar_pattern[16];
+ };
+ 
++static inline struct mt76_connac_txp_common *
++mt7996_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t)
++{
++	u8 *txwi;
++
++	if (!t)
++		return NULL;
++
++	txwi = mt76_get_txwi_ptr(dev, t);
++
++	return (struct mt76_connac_txp_common *)(txwi + MT_TXD_SIZE);
++}
++
+ #endif
+diff --git a/mt7996/mmio.c b/mt7996/mmio.c
+index 902370a2..2237f50a 100644
+--- a/mt7996/mmio.c
++++ b/mt7996/mmio.c
+@@ -326,7 +326,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev,
+ 				SURVEY_INFO_TIME_BSS_RX,
+ 		.token_size = MT7996_TOKEN_SIZE,
+ 		.tx_prepare_skb = mt7996_tx_prepare_skb,
+-		.tx_complete_skb = mt76_connac_tx_complete_skb,
++		.tx_complete_skb = mt7996_tx_complete_skb,
+ 		.rx_skb = mt7996_queue_rx_skb,
+ 		.rx_check = mt7996_rx_check,
+ 		.rx_poll_complete = mt7996_rx_poll_complete,
+diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
+index 018dfd2b..13f22432 100644
+--- a/mt7996/mt7996.h
++++ b/mt7996/mt7996.h
+@@ -508,6 +508,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
+ 			  enum mt76_txq_id qid, struct mt76_wcid *wcid,
+ 			  struct ieee80211_sta *sta,
+ 			  struct mt76_tx_info *tx_info);
++void mt7996_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e);
+ void mt7996_tx_token_put(struct mt7996_dev *dev);
+ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
+ 			 struct sk_buff *skb, u32 *info);
+-- 
+2.25.1
+