blob: 33c0bc7a9230dbd1b0acd06dff8c7e26c46a3d6a [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From ce85a854c7b07de8cb560417a038a2c9870c61e5 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
3Date: Mon, 17 Jun 2024 17:16:19 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 162/223] mtk: mt76: mt7996: change source of per-WCID TX MPDU
developer05f3b2b2024-08-19 19:17:34 +08005 statistics
6
7Change source of per-WCID TX MPDU statistics from TX-free-done event to PPDU TXS, because WCID from TX-free-done event may not represent the actually used link.
8
developerd0c89452024-10-11 16:53:27 +08009Change-Id: If4276b3cc779f79f29c7354c9ac2140a2fd8d852
developer05f3b2b2024-08-19 19:17:34 +080010Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
11---
12 mt76.h | 1 +
13 mt76_connac3_mac.h | 5 +++++
14 mt7996/mac.c | 50 +++++++++++++++++++++++++---------------------
15 3 files changed, 33 insertions(+), 23 deletions(-)
16
17diff --git a/mt76.h b/mt76.h
developerd0c89452024-10-11 16:53:27 +080018index 62ae2662..c3b71cc3 100644
developer05f3b2b2024-08-19 19:17:34 +080019--- a/mt76.h
20+++ b/mt76.h
developerd0c89452024-10-11 16:53:27 +080021@@ -364,6 +364,7 @@ struct mt76_sta_stats {
developer05f3b2b2024-08-19 19:17:34 +080022 u64 tx_bytes;
23 /* WED TX */
24 u32 tx_packets; /* unit: MSDU */
25+ u32 tx_mpdus;
26 u32 tx_retries;
27 u32 tx_failed;
28 u64 tx_airtime;
29diff --git a/mt76_connac3_mac.h b/mt76_connac3_mac.h
30index db0c29e6..ad8392cd 100644
31--- a/mt76_connac3_mac.h
32+++ b/mt76_connac3_mac.h
33@@ -204,6 +204,11 @@ enum tx_frag_idx {
34 MT_TX_FRAG_LAST
35 };
36
37+enum {
38+ MT_TXS_MPDU_FMT = 0,
39+ MT_TXS_PPDU_FMT = 2,
40+};
41+
42 #define MT_CT_INFO_APPLY_TXD BIT(0)
43 #define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1)
44 #define MT_CT_INFO_MGMT_FRAME BIT(2)
45diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080046index 3cd034cd..87e671a3 100644
developer05f3b2b2024-08-19 19:17:34 +080047--- a/mt7996/mac.c
48+++ b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080049@@ -1218,19 +1218,9 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer05f3b2b2024-08-19 19:17:34 +080050 spin_unlock_bh(&mdev->sta_poll_lock);
51 continue;
52 } else if (info & MT_TXFREE_INFO_HEADER) {
53- u32 tx_retries = 0, tx_failed = 0;
54-
55 if (!wcid)
56 continue;
57
58- tx_retries =
59- FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1;
60- tx_failed = tx_retries +
61- !!FIELD_GET(MT_TXFREE_INFO_STAT, info);
62-
63- wcid->stats.tx_retries += tx_retries;
64- wcid->stats.tx_failed += tx_failed;
65-
66 if (FIELD_GET(MT_TXFREE_INFO_STAT, info) == 2) {
67 struct mt7996_phy *mphy =
68 __mt7996_phy(dev, wcid->phy_idx);
developerd0c89452024-10-11 16:53:27 +080069@@ -1268,9 +1258,10 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer05f3b2b2024-08-19 19:17:34 +080070
71 static bool
72 mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
73- int pid, __le32 *txs_data)
74+ struct mt76_wcid *link_wcid, int pid, __le32 *txs_data)
75 {
76- struct mt76_sta_stats *stats = &wcid->stats;
77+ u8 fmt = le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT);
78+ struct mt76_sta_stats *stats = &link_wcid->stats;
79 struct mt76_dev *mdev = &dev->mt76;
80 struct ieee80211_tx_info *info;
81 struct sk_buff_head list;
developerd0c89452024-10-11 16:53:27 +080082@@ -1282,8 +1273,9 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
developer05f3b2b2024-08-19 19:17:34 +080083
84 mt76_tx_status_lock(mdev, &list);
85
86- /* only report MPDU TXS */
87- if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) == 0) {
88+ switch (fmt) {
89+ case MT_TXS_MPDU_FMT:
90+ /* Only report MPDU TXS to mac80211. */
91 skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list);
92 if (skb) {
93 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
developerd0c89452024-10-11 16:53:27 +080094@@ -1312,6 +1304,15 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
developer05f3b2b2024-08-19 19:17:34 +080095 mvif->probe_send_count[wcid->phy_idx] = 0;
96 }
97 }
98+ break;
99+ case MT_TXS_PPDU_FMT:
100+ stats->tx_mpdus += le32_get_bits(txs_data[5], MT_TXS5_MPDU_TX_CNT);
101+ stats->tx_failed += le32_get_bits(txs_data[6], MT_TXS6_MPDU_FAIL_CNT);
102+ stats->tx_retries += le32_get_bits(txs_data[7], MT_TXS7_MPDU_RETRY_CNT);
103+ break;
104+ default:
105+ dev_err(mdev->dev, "Unknown TXS format: %hhu\n", fmt);
106+ goto unlock;
107 }
108
109 if (mtk_wed_device_active(&dev->mt76.mmio.wed) && wcid->sta) {
developerd0c89452024-10-11 16:53:27 +0800110@@ -1343,6 +1344,7 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
developer05f3b2b2024-08-19 19:17:34 +0800111
112 if (skb)
113 mt76_tx_status_skb_done(mdev, skb, &list);
114+unlock:
115 mt76_tx_status_unlock(mdev, &list);
116
117 return !!skb;
developerd0c89452024-10-11 16:53:27 +0800118@@ -1350,13 +1352,13 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
developer05f3b2b2024-08-19 19:17:34 +0800119
120 static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
121 {
122- struct mt7996_link_sta *mlink;
123- struct mt76_wcid *wcid;
124+ struct mt76_wcid *wcid, *link_wcid;
125 __le32 *txs_data = data;
126 u16 wcidx;
127- u8 pid;
128+ u8 band, pid;
129
130 wcidx = le32_get_bits(txs_data[2], MT_TXS2_WCID);
131+ band = le32_get_bits(txs_data[2], MT_TXS2_BAND);
132 pid = le32_get_bits(txs_data[3], MT_TXS3_PID);
133
134 if (pid < MT_PACKET_ID_NO_SKB)
developerd0c89452024-10-11 16:53:27 +0800135@@ -1371,17 +1373,19 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
developer05f3b2b2024-08-19 19:17:34 +0800136 if (!wcid)
137 goto out;
138
139- mt7996_mac_add_txs_skb(dev, wcid, pid, txs_data);
140+ link_wcid = mt7996_get_link_wcid(dev, wcidx, band);
141+ if (!link_wcid)
142+ goto out;
143+
144+ mt7996_mac_add_txs_skb(dev, wcid, link_wcid, pid, txs_data);
145
146- if (!wcid->sta)
147+ if (!link_wcid->sta)
148 goto out;
149
150- mlink = wcid_to_mlink(wcid);
151 spin_lock_bh(&dev->mt76.sta_poll_lock);
152- if (list_empty(&mlink->wcid.poll_list))
153- list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);
154+ if (list_empty(&link_wcid->poll_list))
155+ list_add_tail(&link_wcid->poll_list, &dev->mt76.sta_poll_list);
156 spin_unlock_bh(&dev->mt76.sta_poll_lock);
157-
158 out:
159 rcu_read_unlock();
160 }
161--
developerd0c89452024-10-11 16:53:27 +08001622.45.2
developer05f3b2b2024-08-19 19:17:34 +0800163