blob: 54dff6df3ff533c27fd6ffd0adeca8f06f7f6452 [file] [log] [blame]
developer22eedcc2023-05-03 22:59:35 +08001From 769ca30484c3c8a3e84b11d27cf71b77cdb65c0f Mon Sep 17 00:00:00 2001
developer33554a22023-01-30 14:11:29 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Wed, 18 Jan 2023 11:50:38 +0800
developer22eedcc2023-05-03 22:59:35 +08004Subject: [PATCH] wifi: mt76: mt7915: enable PPDU-TxS to host when wed enable
developer33554a22023-01-30 14:11:29 +08005
6Calculate tx bytes and tx retries from PPDU-TxS
7---
8 mt76_connac_mac.c | 2 --
9 mt7915/init.c | 6 ++++++
10 mt7915/mmio.c | 21 ---------------------
developer22eedcc2023-05-03 22:59:35 +080011 tx.c | 21 +++++++++++++++++++++
12 4 files changed, 27 insertions(+), 23 deletions(-)
developer33554a22023-01-30 14:11:29 +080013
14diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
developer22eedcc2023-05-03 22:59:35 +080015index abcb9a27..5a5861a8 100644
developer33554a22023-01-30 14:11:29 +080016--- a/mt76_connac_mac.c
17+++ b/mt76_connac_mac.c
18@@ -490,8 +490,6 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
19 mt76_connac_lmac_mapping(skb_get_queue_mapping(skb));
20
21 /* counting non-offloading skbs */
22- wcid->stats.tx_bytes += skb->len;
23-
24 if (is_mt7915(dev))
25 wcid->stats.tx_packets++;
26 }
27diff --git a/mt7915/init.c b/mt7915/init.c
developer22eedcc2023-05-03 22:59:35 +080028index 21286a6d..6f309d0d 100644
developer33554a22023-01-30 14:11:29 +080029--- a/mt7915/init.c
30+++ b/mt7915/init.c
developer4f0d84b2023-03-03 14:21:44 +080031@@ -503,6 +503,12 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band)
developer33554a22023-01-30 14:11:29 +080032 set = FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_MODE, 0) |
33 FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_PARAM, 0x3);
34 mt76_rmw(dev, MT_WTBLOFF_TOP_RSCR(band), mask, set);
35+
36+ /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
37+ * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
38+ */
39+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
40+ mt76_set(dev, MT_AGG_ACR4(band), MT_AGG_ACR_PPDU_TXS2H);
41 }
42
43 static void
44diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer22eedcc2023-05-03 22:59:35 +080045index fc9aadb1..65ee2afa 100644
developer33554a22023-01-30 14:11:29 +080046--- a/mt7915/mmio.c
47+++ b/mt7915/mmio.c
48@@ -551,7 +551,6 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
49 static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
50 {
51 struct mt7915_dev *dev;
52- struct mt7915_phy *phy;
53 int ret;
54
55 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
56@@ -565,38 +564,18 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
57 if (!ret)
58 return -EAGAIN;
59
60- phy = &dev->phy;
61- mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
62-
63- phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
64- if (phy)
65- mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx),
66- MT_AGG_ACR_PPDU_TXS2H);
67-
68 return 0;
69 }
70
71 static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
72 {
73 struct mt7915_dev *dev;
74- struct mt7915_phy *phy;
75
76 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
77
78 spin_lock_bh(&dev->mt76.token_lock);
79 dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
80 spin_unlock_bh(&dev->mt76.token_lock);
81-
82- /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
83- * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
84- */
85- phy = &dev->phy;
86- mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
87-
88- phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
89- if (phy)
90- mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx),
91- MT_AGG_ACR_PPDU_TXS2H);
92 }
93
94 static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed)
95diff --git a/tx.c b/tx.c
developer22eedcc2023-05-03 22:59:35 +080096index 25683c1f..823c8680 100644
developer33554a22023-01-30 14:11:29 +080097--- a/tx.c
98+++ b/tx.c
developer6100db22023-04-05 13:22:26 +080099@@ -120,6 +120,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
developer33554a22023-01-30 14:11:29 +0800100 struct sk_buff *skb)
101 {
102 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
103+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
104 struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb);
105 int pid;
106
developer6100db22023-04-05 13:22:26 +0800107@@ -131,6 +132,11 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
developer33554a22023-01-30 14:11:29 +0800108 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
109 return MT_PACKET_ID_NO_ACK;
110
111+ if (mtk_wed_device_active(&dev->mmio.wed) &&
112+ ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ||
113+ ieee80211_is_data(hdr->frame_control)))
114+ return MT_PACKET_ID_WED;
115+
116 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
117 IEEE80211_TX_CTL_RATE_CTRL_PROBE)))
118 return MT_PACKET_ID_NO_SKB;
developer22eedcc2023-05-03 22:59:35 +0800119@@ -260,8 +266,23 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
120 #endif
121
developer7ce8c7d2023-04-10 11:29:30 +0800122 if (cb->pktid < MT_PACKET_ID_FIRST) {
developer22eedcc2023-05-03 22:59:35 +0800123+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
124+ struct ieee80211_rate_status rs = {};
125+
developer7ce8c7d2023-04-10 11:29:30 +0800126 hw = mt76_tx_status_get_hw(dev, skb);
127 status.sta = wcid_to_sta(wcid);
128+ if (mtk_wed_device_active(&dev->mmio.wed) &&
129+ (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) {
developer22eedcc2023-05-03 22:59:35 +0800130+ info->status.rates[0].idx = -1;
131+
132+ if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) {
133+ rs.rate_idx = wcid->rate;
134+ status.rates = &rs;
135+ status.n_rates = 1;
136+ } else {
137+ status.n_rates = 0;
developer7ce8c7d2023-04-10 11:29:30 +0800138+ }
139+ }
140 ieee80211_tx_status_ext(hw, &status);
141 goto out;
142 }
developer33554a22023-01-30 14:11:29 +0800143--
developer7ce8c7d2023-04-10 11:29:30 +08001442.18.0
developer33554a22023-01-30 14:11:29 +0800145