blob: 63744a867a55405ecc9bc5cfbc07a24716c21fed [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From 475282f29cf4364626cf6146d78da23640ea7dfd 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
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 3008/3012] wifi: mt76: mt7915: enable PPDU-TxS to host when
5 wed enable
developer33554a22023-01-30 14:11:29 +08006
7Calculate tx bytes and tx retries from PPDU-TxS
8---
9 mt76_connac_mac.c | 2 --
10 mt7915/init.c | 6 ++++++
11 mt7915/mmio.c | 21 ---------------------
developer22eedcc2023-05-03 22:59:35 +080012 tx.c | 21 +++++++++++++++++++++
13 4 files changed, 27 insertions(+), 23 deletions(-)
developer33554a22023-01-30 14:11:29 +080014
15diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
developerbbd45e12023-05-19 08:22:06 +080016index 6cd8c27..8b77e93 100644
developer33554a22023-01-30 14:11:29 +080017--- a/mt76_connac_mac.c
18+++ b/mt76_connac_mac.c
developerbbd45e12023-05-19 08:22:06 +080019@@ -522,8 +522,6 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
developer33554a22023-01-30 14:11:29 +080020 mt76_connac_lmac_mapping(skb_get_queue_mapping(skb));
21
22 /* counting non-offloading skbs */
23- wcid->stats.tx_bytes += skb->len;
24-
25 if (is_mt7915(dev))
26 wcid->stats.tx_packets++;
27 }
28diff --git a/mt7915/init.c b/mt7915/init.c
developerbbd45e12023-05-19 08:22:06 +080029index 8684d7a..9036f44 100644
developer33554a22023-01-30 14:11:29 +080030--- a/mt7915/init.c
31+++ b/mt7915/init.c
developerbbd45e12023-05-19 08:22:06 +080032@@ -507,6 +507,12 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band)
developer33554a22023-01-30 14:11:29 +080033 set = FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_MODE, 0) |
34 FIELD_PREP(MT_WTBLOFF_TOP_RSCR_RCPI_PARAM, 0x3);
35 mt76_rmw(dev, MT_WTBLOFF_TOP_RSCR(band), mask, set);
36+
37+ /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
38+ * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
39+ */
40+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
41+ mt76_set(dev, MT_AGG_ACR4(band), MT_AGG_ACR_PPDU_TXS2H);
42 }
43
44 static void
45diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developerbbd45e12023-05-19 08:22:06 +080046index 1c416bc..bbaaa33 100644
developer33554a22023-01-30 14:11:29 +080047--- a/mt7915/mmio.c
48+++ b/mt7915/mmio.c
49@@ -551,7 +551,6 @@ static u32 mt7915_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
50 static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
51 {
52 struct mt7915_dev *dev;
53- struct mt7915_phy *phy;
54 int ret;
55
56 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
57@@ -565,38 +564,18 @@ static int mt7915_mmio_wed_offload_enable(struct mtk_wed_device *wed)
58 if (!ret)
59 return -EAGAIN;
60
61- phy = &dev->phy;
62- mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
63-
64- phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
65- if (phy)
66- mt76_set(dev, MT_AGG_ACR4(phy->mt76->band_idx),
67- MT_AGG_ACR_PPDU_TXS2H);
68-
69 return 0;
70 }
71
72 static void mt7915_mmio_wed_offload_disable(struct mtk_wed_device *wed)
73 {
74 struct mt7915_dev *dev;
75- struct mt7915_phy *phy;
76
77 dev = container_of(wed, struct mt7915_dev, mt76.mmio.wed);
78
79 spin_lock_bh(&dev->mt76.token_lock);
80 dev->mt76.token_size = wed->wlan.token_start;//MT7915_TOKEN_SIZE
81 spin_unlock_bh(&dev->mt76.token_lock);
82-
83- /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
84- * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
85- */
86- phy = &dev->phy;
87- mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx), MT_AGG_ACR_PPDU_TXS2H);
88-
89- phy = dev->mt76.phys[MT_BAND1] ? dev->mt76.phys[MT_BAND1]->priv : NULL;
90- if (phy)
91- mt76_clear(dev, MT_AGG_ACR4(phy->mt76->band_idx),
92- MT_AGG_ACR_PPDU_TXS2H);
93 }
94
95 static void mt7915_mmio_wed_release_rx_buf(struct mtk_wed_device *wed)
96diff --git a/tx.c b/tx.c
developerbbd45e12023-05-19 08:22:06 +080097index a87e361..335ddb5 100644
developer33554a22023-01-30 14:11:29 +080098--- a/tx.c
99+++ b/tx.c
developerbbd45e12023-05-19 08:22:06 +0800100@@ -122,6 +122,7 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
developer33554a22023-01-30 14:11:29 +0800101 struct sk_buff *skb)
102 {
103 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
104+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
105 struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb);
106 int pid;
107
developerbbd45e12023-05-19 08:22:06 +0800108@@ -133,6 +134,11 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
developer33554a22023-01-30 14:11:29 +0800109 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
110 return MT_PACKET_ID_NO_ACK;
111
112+ if (mtk_wed_device_active(&dev->mmio.wed) &&
113+ ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ||
114+ ieee80211_is_data(hdr->frame_control)))
115+ return MT_PACKET_ID_WED;
116+
117 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
118 IEEE80211_TX_CTL_RATE_CTRL_PROBE)))
119 return MT_PACKET_ID_NO_SKB;
developerbbd45e12023-05-19 08:22:06 +0800120@@ -262,8 +268,23 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
developer22eedcc2023-05-03 22:59:35 +0800121 #endif
122
developer7ce8c7d2023-04-10 11:29:30 +0800123 if (cb->pktid < MT_PACKET_ID_FIRST) {
developer22eedcc2023-05-03 22:59:35 +0800124+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
125+ struct ieee80211_rate_status rs = {};
126+
developer7ce8c7d2023-04-10 11:29:30 +0800127 hw = mt76_tx_status_get_hw(dev, skb);
128 status.sta = wcid_to_sta(wcid);
129+ if (mtk_wed_device_active(&dev->mmio.wed) &&
130+ (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) {
developer22eedcc2023-05-03 22:59:35 +0800131+ info->status.rates[0].idx = -1;
132+
133+ if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) {
134+ rs.rate_idx = wcid->rate;
135+ status.rates = &rs;
136+ status.n_rates = 1;
137+ } else {
138+ status.n_rates = 0;
developer7ce8c7d2023-04-10 11:29:30 +0800139+ }
140+ }
developerbbd45e12023-05-19 08:22:06 +0800141 spin_lock_bh(&dev->rx_lock);
developer7ce8c7d2023-04-10 11:29:30 +0800142 ieee80211_tx_status_ext(hw, &status);
developerbbd45e12023-05-19 08:22:06 +0800143 spin_unlock_bh(&dev->rx_lock);
developer33554a22023-01-30 14:11:29 +0800144--
developer7ce8c7d2023-04-10 11:29:30 +08001452.18.0
developer33554a22023-01-30 14:11:29 +0800146