[][MAC80211][Rebase][mt76: rebase to 0513]

[Description]
Refactor mt76 patches based on the latest mt76 master.
(commit: 969b7b5ebd129068ca56e4b0d831593a2f92382f)

[Release-log]
N/A

Change-Id: I1f8a5aed77a64d7fc6a2c6b45077ca5683d45b79
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7512199
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/3008-wifi-mt76-mt7915-enable-PPDU-TxS-to-host-when-wed-en.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/3008-wifi-mt76-mt7915-enable-PPDU-TxS-to-host-when-wed-en.patch
new file mode 100644
index 0000000..63744a8
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/3008-wifi-mt76-mt7915-enable-PPDU-TxS-to-host-when-wed-en.patch
@@ -0,0 +1,146 @@
+From 475282f29cf4364626cf6146d78da23640ea7dfd Mon Sep 17 00:00:00 2001
+From: Peter Chiu <chui-hao.chiu@mediatek.com>
+Date: Wed, 18 Jan 2023 11:50:38 +0800
+Subject: [PATCH 3008/3012] wifi: mt76: mt7915: enable PPDU-TxS to host when
+ wed enable
+
+Calculate tx bytes and tx retries from PPDU-TxS
+---
+ mt76_connac_mac.c |  2 --
+ mt7915/init.c     |  6 ++++++
+ mt7915/mmio.c     | 21 ---------------------
+ tx.c              | 21 +++++++++++++++++++++
+ 4 files changed, 27 insertions(+), 23 deletions(-)
+
+diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
+index 6cd8c27..8b77e93 100644
+--- a/mt76_connac_mac.c
++++ b/mt76_connac_mac.c
+@@ -522,8 +522,6 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
+ 			mt76_connac_lmac_mapping(skb_get_queue_mapping(skb));
+ 
+ 		/* counting non-offloading skbs */
+-		wcid->stats.tx_bytes += skb->len;
+-
+ 		if (is_mt7915(dev))
+ 			wcid->stats.tx_packets++;
+ 	}
+diff --git a/mt7915/init.c b/mt7915/init.c
+index 8684d7a..9036f44 100644
+--- a/mt7915/init.c
++++ b/mt7915/init.c
+@@ -507,6 +507,12 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band)
+ 	set = FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_MODE, 0) |
+ 	      FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_PARAM, 0x3);
+ 	mt76_rmw(dev, MT_WTBLOFF_TOP_RSCR(band), mask, set);
++
++	/* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
++	 * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
++	 */
++	if (mtk_wed_device_active(&dev->mt76.mmio.wed))
++		mt76_set(dev, MT_AGG_ACR4(band), MT_AGG_ACR_PPDU_TXS2H);
+ }
+ 
+ static void
+diff --git a/mt7915/mmio.c b/mt7915/mmio.c
+index 1c416bc..bbaaa33 100644
+--- a/mt7915/mmio.c
++++ b/mt7915/mmio.c
+@@ -551,7 +551,6 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
+ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
+ {
+ 	struct mt7915_dev *dev;
+-	struct mt7915_phy *phy;
+ 	int ret;
+ 
+ 	dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
+@@ -565,38 +564,18 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
+ 	if (!ret)
+ 		return -EAGAIN;
+ 
+-	phy = &dev->phy;
+-	mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
+-
+-	phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
+-	if (phy)
+-		mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx),
+-			 MT_AGG_ACR_PPDU_TXS2H);
+-
+ 	return 0;
+ }
+ 
+ static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
+ {
+ 	struct mt7915_dev *dev;
+-	struct mt7915_phy *phy;
+ 
+ 	dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
+ 
+ 	spin_lock_bh(&dev->mt76.token_lock);
+ 	dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
+ 	spin_unlock_bh(&dev->mt76.token_lock);
+-
+-	/* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
+-	 * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
+-	 */
+-	phy = &dev->phy;
+-	mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
+-
+-	phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
+-	if (phy)
+-		mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx),
+-			   MT_AGG_ACR_PPDU_TXS2H);
+ }
+ 
+ static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed)
+diff --git a/tx.c b/tx.c
+index a87e361..335ddb5 100644
+--- a/tx.c
++++ b/tx.c
+@@ -122,6 +122,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
+ 		       struct sk_buff *skb)
+ {
+ 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
++	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ 	struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb);
+ 	int pid;
+ 
+@@ -133,6 +134,11 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
+ 	if (info->flags & IEEE80211_TX_CTL_NO_ACK)
+ 		return MT_PACKET_ID_NO_ACK;
+ 
++	if (mtk_wed_device_active(&dev->mmio.wed) &&
++	    ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ||
++	    ieee80211_is_data(hdr->frame_control)))
++		return MT_PACKET_ID_WED;
++
+ 	if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
+ 			     IEEE80211_TX_CTL_RATE_CTRL_PROBE)))
+ 		return MT_PACKET_ID_NO_SKB;
+@@ -262,8 +268,23 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
+ #endif
+ 
+ 	if (cb->pktid < MT_PACKET_ID_FIRST) {
++		struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
++		struct ieee80211_rate_status rs = {};
++
+ 		hw = mt76_tx_status_get_hw(dev, skb);
+ 		status.sta = wcid_to_sta(wcid);
++		if (mtk_wed_device_active(&dev->mmio.wed) &&
++		    (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) {
++			info->status.rates[0].idx = -1;
++
++			if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) {
++				rs.rate_idx = wcid->rate;
++				status.rates = &rs;
++				status.n_rates = 1;
++			} else {
++				status.n_rates = 0;
++			}
++		}
+ 		spin_lock_bh(&dev->rx_lock);
+ 		ieee80211_tx_status_ext(hw, &status);
+ 		spin_unlock_bh(&dev->rx_lock);
+-- 
+2.18.0
+