blob: e4e034393904fc98236ec68f39da9ebe948c2f83 [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From 7fad725b238b5b94403b9c4457aa0c3c0acdd576 Mon Sep 17 00:00:00 2001
developer33554a22023-01-30 14:11:29 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 17 Jan 2023 21:15:00 +0800
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 3009/3012] wifi: mt76: mt7915: get tx retries from tx free
developer4f0d84b2023-03-03 14:21:44 +08005 done event for sw path
developer33554a22023-01-30 14:11:29 +08006
7---
developerbbd45e12023-05-19 08:22:06 +08008 mt76_connac2_mac.h | 2 ++
9 mt7915/mac.c | 14 +++++++++++---
10 mt7915/mac.h | 3 ++-
11 mt7915/main.c | 6 +++---
12 4 files changed, 18 insertions(+), 7 deletions(-)
developer33554a22023-01-30 14:11:29 +080013
developerbbd45e12023-05-19 08:22:06 +080014diff --git a/mt76_connac2_mac.h b/mt76_connac2_mac.h
15index e7a4019..e6170ea 100644
16--- a/mt76_connac2_mac.h
17+++ b/mt76_connac2_mac.h
18@@ -38,6 +38,8 @@ enum {
19 /* 0: success, others: dropped */
20 #define MT_TX_FREE_STATUS GENMASK(14, 13)
21 #define MT_TX_FREE_MSDU_ID GENMASK(30, 16)
22+#define MT_TX_FREE_TX_COUNT GENMASK(12, 0)
23+#define MT_TX_FREE_TX_COUNT_V3 GENMASK(27, 24)
24 #define MT_TX_FREE_PAIR BIT(31)
25 /* will support this field in further revision */
26 #define MT_TX_FREE_RATE GENMASK(13, 0)
developer33554a22023-01-30 14:11:29 +080027diff --git a/mt7915/mac.c b/mt7915/mac.c
developerbbd45e12023-05-19 08:22:06 +080028index 26b5e15..0994ce1 100644
developer33554a22023-01-30 14:11:29 +080029--- a/mt7915/mac.c
30+++ b/mt7915/mac.c
developerbbd45e12023-05-19 08:22:06 +080031@@ -981,6 +981,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer33554a22023-01-30 14:11:29 +080032 struct mt76_dev *mdev = &dev->mt76;
33 struct mt76_txwi_cache *txwi;
34 struct ieee80211_sta *sta = NULL;
35+ struct mt76_wcid *wcid = NULL;
36 LIST_HEAD(free_list);
37 void *end = data + len;
38 bool v3, wake = false;
developerbbd45e12023-05-19 08:22:06 +080039@@ -995,7 +996,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer33554a22023-01-30 14:11:29 +080040 v3 = (FIELD_GET(MT_TX_FREE_VER, txd) == 0x4);
41
42 for (cur_info = tx_info; count < total; cur_info++) {
43- u32 msdu, info;
44+ u32 msdu, info, retries = 0;
45 u8 i;
46
47 if (WARN_ON_ONCE((void *)cur_info >= end))
developerbbd45e12023-05-19 08:22:06 +080048@@ -1008,7 +1009,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer33554a22023-01-30 14:11:29 +080049 info = le32_to_cpu(*cur_info);
50 if (info & MT_TX_FREE_PAIR) {
51 struct mt7915_sta *msta;
52- struct mt76_wcid *wcid = NULL;
developer5bea7322023-04-13 18:50:55 +080053 struct mt7915_phy *phy;
developer33554a22023-01-30 14:11:29 +080054 u16 idx;
55
developerbbd45e12023-05-19 08:22:06 +080056@@ -1033,7 +1033,15 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
developer33554a22023-01-30 14:11:29 +080057 continue;
58 }
59
60- if (v3 && (info & MT_TX_FREE_MPDU_HEADER))
61+ if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3))
62+ retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT_V3) - 1;
63+ else if (!v3 && (info & MT_TX_FREE_MPDU_HEADER))
64+ retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT) - 1;
65+
developerd1877ca2023-02-23 11:31:03 +080066+ if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid)
developer33554a22023-01-30 14:11:29 +080067+ wcid->stats.tx_retries += retries;
68+
69+ if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3))
70 continue;
71
72 for (i = 0; i < 1 + v3; i++) {
73diff --git a/mt7915/mac.h b/mt7915/mac.h
developerbbd45e12023-05-19 08:22:06 +080074index ce94f87..859298d 100644
developer33554a22023-01-30 14:11:29 +080075--- a/mt7915/mac.h
76+++ b/mt7915/mac.h
developerbbd45e12023-05-19 08:22:06 +080077@@ -9,7 +9,8 @@
78 #define MT_TX_FREE_VER GENMASK(18, 16)
79 #define MT_TX_FREE_MSDU_CNT_V0 GENMASK(6, 0)
developer33554a22023-01-30 14:11:29 +080080 /* 0: success, others: dropped */
developer33554a22023-01-30 14:11:29 +080081-#define MT_TX_FREE_MPDU_HEADER BIT(30)
82+#define MT_TX_FREE_MPDU_HEADER BIT(15)
83+#define MT_TX_FREE_MPDU_HEADER_V3 BIT(30)
84 #define MT_TX_FREE_MSDU_ID_V3 GENMASK(14, 0)
85
developerbbd45e12023-05-19 08:22:06 +080086 #define MT_TXS5_F0_FINAL_MPDU BIT(31)
developer33554a22023-01-30 14:11:29 +080087diff --git a/mt7915/main.c b/mt7915/main.c
developerbbd45e12023-05-19 08:22:06 +080088index c377ef2..f836aa8 100644
developer33554a22023-01-30 14:11:29 +080089--- a/mt7915/main.c
90+++ b/mt7915/main.c
developerbbd45e12023-05-19 08:22:06 +080091@@ -1116,9 +1116,6 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developer33554a22023-01-30 14:11:29 +080092 sinfo->tx_bytes = msta->wcid.stats.tx_bytes;
93 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
94
95- sinfo->tx_retries = msta->wcid.stats.tx_retries;
96- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
97-
98 if (mtk_wed_get_rx_capa(&phy->dev->mt76.mmio.wed)) {
99 sinfo->rx_bytes = msta->wcid.stats.rx_bytes;
100 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
developerbbd45e12023-05-19 08:22:06 +0800101@@ -1128,6 +1125,9 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
developer33554a22023-01-30 14:11:29 +0800102 }
103 }
104
105+ sinfo->tx_retries = msta->wcid.stats.tx_retries;
106+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
107+
108 if (!mt7915_mcu_get_tx_stat_wa(phy->dev, msta->wcid.idx)) {
109 sinfo->tx_packets = msta->wcid.stats.tx_packets;
110 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
111--
developer2324aa22023-04-12 11:30:15 +08001122.18.0
developer33554a22023-01-30 14:11:29 +0800113