blob: 9705ef966f8234794678775a72f1fa064ca8ab19 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 72119323570a647a238c6d3dfb2c07c190e062c4 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Wed, 7 Sep 2022 12:13:20 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 109/223] mtk: mt76: mt7996: add linux tracing support
developer05f3b2b2024-08-19 19:17:34 +08005
6Add static tracepoint support for besra.
7
developerd0c89452024-10-11 16:53:27 +08008Change-Id: I3209ba360b49c28e49c7cf464ea130aeba993ef7
developer05f3b2b2024-08-19 19:17:34 +08009Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
10---
11 agg-rx.c | 2 +
12 mac80211.c | 3 +
13 mt7996/Makefile | 2 +-
14 mt7996/mac.c | 6 ++
15 mt7996/mcu.c | 8 +++
16 mt7996/mt7996_trace.h | 141 ++++++++++++++++++++++++++++++++++++++++++
17 mt7996/trace.c | 12 ++++
18 trace.h | 58 +++++++++++++++++
19 8 files changed, 231 insertions(+), 1 deletion(-)
20 create mode 100644 mt7996/mt7996_trace.h
21 create mode 100644 mt7996/trace.c
22
23diff --git a/agg-rx.c b/agg-rx.c
24index 07c386c7..b48943c4 100644
25--- a/agg-rx.c
26+++ b/agg-rx.c
27@@ -3,6 +3,7 @@
28 * Copyright (C) 2018 Felix Fietkau <nbd@nbd.name>
29 */
30 #include "mt76.h"
31+#include "trace.h"
32
33 static unsigned long mt76_aggr_tid_to_timeo(u8 tidno)
34 {
35@@ -187,6 +188,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
36 seqno = status->seqno;
37 size = tid->size;
38 sn_less = ieee80211_sn_less(seqno, head);
39+ trace_mt76_rx_aggr_reorder(tid->dev, wcid, head, seqno, sn_less);
40
41 if (!tid->started) {
42 if (sn_less)
43diff --git a/mac80211.c b/mac80211.c
developerd0c89452024-10-11 16:53:27 +080044index a2b111c0..75674462 100644
developer05f3b2b2024-08-19 19:17:34 +080045--- a/mac80211.c
46+++ b/mac80211.c
47@@ -5,6 +5,7 @@
48 #include <linux/sched.h>
49 #include <linux/of.h>
50 #include "mt76.h"
51+#include "trace.h"
52
53 static const struct ieee80211_channel mt76_channels_2ghz[] = {
54 CHAN2G(1, 2412),
developerd0c89452024-10-11 16:53:27 +080055@@ -1332,6 +1333,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
developer05f3b2b2024-08-19 19:17:34 +080056
57 mt76_check_ccmp_pn(skb);
58 skb_shinfo(skb)->frag_list = NULL;
59+ trace_mt76_rx_complete(dev, (struct mt76_rx_status *)skb->cb, 0);
60 mt76_rx_convert(dev, skb, &hw, &sta);
61 ieee80211_rx_list(hw, sta, skb, &list);
62
developerd0c89452024-10-11 16:53:27 +080063@@ -1341,6 +1343,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
developer05f3b2b2024-08-19 19:17:34 +080064 nskb = nskb->next;
65 skb->next = NULL;
66
67+ trace_mt76_rx_complete(dev, (struct mt76_rx_status *)skb->cb, 1);
68 mt76_rx_convert(dev, skb, &hw, &sta);
69 ieee80211_rx_list(hw, sta, skb, &list);
70 }
71diff --git a/mt7996/Makefile b/mt7996/Makefile
72index 49ec9154..936edc61 100644
73--- a/mt7996/Makefile
74+++ b/mt7996/Makefile
75@@ -12,4 +12,4 @@ mt7996e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \
76 mt7996e-$(CONFIG_DEV_COREDUMP) += coredump.o
77 mt7996e-$(CONFIG_NL80211_TESTMODE) += testmode.o
78
79-mt7996e-y += mtk_debugfs.o mtk_mcu.o mtk_debugfs_i.o
80+mt7996e-y += mtk_debugfs.o mtk_mcu.o mtk_debugfs_i.o trace.o
81diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080082index 2e27e3b3..1c0d3676 100644
developer05f3b2b2024-08-19 19:17:34 +080083--- a/mt7996/mac.c
84+++ b/mt7996/mac.c
85@@ -11,6 +11,7 @@
86 #include "mac.h"
87 #include "mcu.h"
88 #include "vendor.h"
89+#include "mt7996_trace.h"
90
91 static const struct mt7996_dfs_radar_spec etsi_radar_specs = {
92 .pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
93@@ -344,6 +345,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
94 phy = mphy->priv;
95 status->phy_idx = mphy->band_idx;
96
97+ trace_mt7996_fill_rx(phy, skb->data, skb->len);
98+
99 if (!test_bit(MT76_STATE_RUNNING, &mphy->state))
100 return -EINVAL;
101
developerd0c89452024-10-11 16:53:27 +0800102@@ -621,6 +624,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
103 }
104 }
developer05f3b2b2024-08-19 19:17:34 +0800105
106+ trace_mt7996_fill_rx_done(phy, status->seqno, hdr_gap);
107+
108 if (!status->wcid || !ieee80211_is_data_qos(fc) || hw_aggr)
109 return 0;
110
developerd0c89452024-10-11 16:53:27 +0800111@@ -1010,6 +1015,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer05f3b2b2024-08-19 19:17:34 +0800112 mt7996_packet_log_to_host(dev, t->skb->data, t->skb->len, PKT_BIN_DEBUG_TX, 0);
113 mt7996_dump_bmac_txd_info(NULL, dev, (__le32 *)txwi, true, false);
114 #endif
115+ trace_mt7996_tx_prepare(dev, wcid, qid, txwi, t->skb->data, t->skb->len);
116
117 return 0;
118 }
119diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800120index 956bd396..d1aa19cb 100644
developer05f3b2b2024-08-19 19:17:34 +0800121--- a/mt7996/mcu.c
122+++ b/mt7996/mcu.c
123@@ -10,6 +10,7 @@
124 #include "mcu.h"
125 #include "mac.h"
126 #include "eeprom.h"
127+#include "mt7996_trace.h"
128
129 #define fw_name(_dev, name, ...) ({ \
130 char *_fw; \
developerd0c89452024-10-11 16:53:27 +0800131@@ -310,6 +311,9 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
developer05f3b2b2024-08-19 19:17:34 +0800132 else if (cmd & __MCU_CMD_FIELD_WM)
133 uni_txd->s2d_index = MCU_S2D_H2N;
134
135+ trace_mt7996_mcu_cmd(dev, 1, uni_txd->cid, 0,
136+ skb->data, skb->len);
137+
138 goto exit;
139 }
140
developerd0c89452024-10-11 16:53:27 +0800141@@ -337,6 +341,8 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
developer05f3b2b2024-08-19 19:17:34 +0800142 else
143 mcu_txd->s2d_index = MCU_S2D_H2N;
144
145+ trace_mt7996_mcu_cmd(dev, 0, mcu_txd->cid, mcu_txd->ext_cid,
146+ skb->data, skb->len);
147 exit:
148 #ifdef CONFIG_MTK_DEBUG
149 if (dev->dbg.dump_mcu_pkt)
developerd0c89452024-10-11 16:53:27 +0800150@@ -1182,6 +1188,8 @@ void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb)
developer05f3b2b2024-08-19 19:17:34 +0800151 {
152 struct mt7996_mcu_rxd *rxd = (struct mt7996_mcu_rxd *)skb->data;
153
154+ trace_mt7996_mcu_event(dev, rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT,
155+ rxd->eid, rxd->ext_eid, skb->data, skb->len);
156 if (rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT) {
157 mt7996_mcu_uni_rx_unsolicited_event(dev, skb);
158 return;
159diff --git a/mt7996/mt7996_trace.h b/mt7996/mt7996_trace.h
160new file mode 100644
161index 00000000..5fa73482
162--- /dev/null
163+++ b/mt7996/mt7996_trace.h
164@@ -0,0 +1,141 @@
165+/* SPDX-License-Identifier: ISC */
166+/*
167+ * Copyright (C) 2022 MediaTek Inc.
168+ */
169+
170+#if !defined(__MT7996_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
171+#define __MT7996_TRACE_H
172+
173+#include <linux/types.h>
174+#include <linux/tracepoint.h>
175+#include "mt7996.h"
176+
177+#undef TRACE_SYSTEM
178+#define TRACE_SYSTEM mt7996
179+
180+#define MAXNAME 32
181+#define DEV_ENTRY __array(char, wiphy_name, 32)
182+#define DEV_ASSIGN(_w) strlcpy(__entry->wiphy_name, wiphy_name(_w), MAXNAME)
183+#define DEV_PR_FMT "%s"
184+#define DEV_PR_ARG __entry->wiphy_name
185+
186+DECLARE_EVENT_CLASS(mt7996_mcu_debug,
187+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
188+ const void *data, size_t len),
189+ TP_ARGS(dev, uni, id, ext_id, data, len),
190+ TP_STRUCT__entry(
191+ __field(bool, uni)
192+ __field(u8, id)
193+ __field(u8, ext_id)
194+ __field(size_t, len)
195+ __dynamic_array(u8, data, len)
196+ ),
197+ TP_fast_assign(
198+ __entry->uni = uni;
199+ __entry->id = id;
200+ __entry->ext_id = ext_id;
201+ __entry->len = len;
202+ memcpy(__get_dynamic_array(data), data, len);
203+ ),
204+ TP_printk(
205+ "uni: %d, id: %u, ext_id: %u, len: %zu",
206+ __entry->uni,
207+ __entry->id,
208+ __entry->ext_id,
209+ __entry->len
210+ )
211+);
212+
213+DEFINE_EVENT(mt7996_mcu_debug, mt7996_mcu_cmd,
214+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
215+ const void *data, size_t len),
216+ TP_ARGS(dev, uni, id, ext_id, data, len)
217+);
218+
219+DEFINE_EVENT(mt7996_mcu_debug, mt7996_mcu_event,
220+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
221+ const void *data, size_t len),
222+ TP_ARGS(dev, uni, id, ext_id, data, len)
223+);
224+
225+TRACE_EVENT(mt7996_tx_prepare,
226+ TP_PROTO(struct mt7996_dev *dev, struct mt76_wcid *wcid, enum mt76_txq_id qid,
227+ const void *txwi, const void *data, size_t len),
228+ TP_ARGS(dev, wcid, qid, txwi, data, len),
229+
230+ TP_STRUCT__entry(
231+ DEV_ENTRY
232+ __field(u16, wcid)
233+ __field(u8, qid)
234+ __array(u8, txwi, MT_TXD_SIZE)
235+ __field(size_t, len)
236+ __dynamic_array(u8, data, len)
237+ ),
238+
239+ TP_fast_assign(
240+ DEV_ASSIGN(dev->mt76.phys[wcid->phy_idx]->hw->wiphy);
241+ __entry->wcid = wcid->idx;
242+ __entry->qid = qid;
243+ memcpy(__entry->txwi, txwi, MT_TXD_SIZE);
244+ __entry->len = len;
245+ memcpy(__get_dynamic_array(data), data, len);
246+ ),
247+
248+ TP_printk(
249+ DEV_PR_FMT " wcid: %u, qid: %u, len: %zu",
250+ DEV_PR_ARG, __entry->wcid, __entry->qid, __entry->len
251+ )
252+);
253+
254+TRACE_EVENT(mt7996_fill_rx,
255+ TP_PROTO(struct mt7996_phy *phy, const void *data, size_t len),
256+ TP_ARGS(phy, data, len),
257+
258+ TP_STRUCT__entry(
259+ DEV_ENTRY
260+ __field(size_t, len)
261+ __dynamic_array(u8, data, len)
262+ ),
263+
264+ TP_fast_assign(
265+ DEV_ASSIGN(phy->mt76->hw->wiphy);
266+ __entry->len = len;
267+ memcpy(__get_dynamic_array(data), data, len);
268+ ),
269+
270+ TP_printk(
271+ DEV_PR_FMT " len: %zu",
272+ DEV_PR_ARG, __entry->len
273+ )
274+);
275+
276+TRACE_EVENT(mt7996_fill_rx_done,
277+ TP_PROTO(struct mt7996_phy *phy, u16 seqno, u16 hdr_gap),
278+ TP_ARGS(phy, seqno, hdr_gap),
279+
280+ TP_STRUCT__entry(
281+ DEV_ENTRY
282+ __field(u16, seqno)
283+ __field(u16, hdr_gap)
284+ ),
285+
286+ TP_fast_assign(
287+ DEV_ASSIGN(phy->mt76->hw->wiphy);
288+ __entry->seqno = seqno;
289+ __entry->hdr_gap = hdr_gap;
290+ ),
291+
292+ TP_printk(
293+ DEV_PR_FMT " seqno: %u, hdr_gap: %u",
294+ DEV_PR_ARG, __entry->seqno, __entry->hdr_gap
295+ )
296+);
297+
298+#endif
299+
300+#undef TRACE_INCLUDE_PATH
301+#define TRACE_INCLUDE_PATH ./mt7996
302+#undef TRACE_INCLUDE_FILE
303+#define TRACE_INCLUDE_FILE mt7996_trace
304+
305+#include <trace/define_trace.h>
306diff --git a/mt7996/trace.c b/mt7996/trace.c
307new file mode 100644
308index 00000000..ba36f79a
309--- /dev/null
310+++ b/mt7996/trace.c
311@@ -0,0 +1,12 @@
312+/* SPDX-License-Identifier: ISC */
313+/*
314+ * Copyright (C) 2022 MediaTek Inc.
315+ */
316+
317+#include <linux/module.h>
318+
319+#ifndef __CHECKER__
320+#define CREATE_TRACE_POINTS
321+#include "mt7996_trace.h"
322+
323+#endif
324diff --git a/trace.h b/trace.h
325index c3d0ef8e..57c94c6b 100644
326--- a/trace.h
327+++ b/trace.h
328@@ -101,6 +101,64 @@ DEFINE_EVENT(dev_txid_evt, mac_txdone,
329 TP_ARGS(dev, wcid, pktid)
330 );
331
332+TRACE_EVENT(mt76_rx_complete,
333+ TP_PROTO(struct mt76_dev *dev, struct mt76_rx_status *status, bool sub),
334+ TP_ARGS(dev, status, sub),
335+
336+ TP_STRUCT__entry(
337+ DEV_ENTRY
338+ __field(u16, seqno)
339+ __field(u16, wcid)
340+ __field(u8, first_amsdu)
341+ __field(bool, sub)
342+ ),
343+
344+ TP_fast_assign(
345+ strlcpy(__entry->wiphy_name,
346+ wiphy_name(mt76_dev_phy(dev, status->phy_idx)->hw->wiphy),
347+ MAXNAME);
348+ __entry->seqno = status->seqno;
349+ __entry->wcid = status->wcid ? status->wcid->idx : 0;
350+ __entry->first_amsdu = status->first_amsdu;
351+ __entry->sub = sub;
352+ ),
353+
354+ TP_printk(
355+ DEV_PR_FMT " seqno: %u, wcid: %u, first_amsdu: %x, sub: %d",
356+ DEV_PR_ARG, __entry->seqno, __entry->wcid, __entry->first_amsdu,
357+ __entry->sub
358+ )
359+);
360+
361+TRACE_EVENT(mt76_rx_aggr_reorder,
362+ TP_PROTO(struct mt76_dev *dev, struct mt76_wcid *wcid, u16 _head, u16 seqno, bool sn_less),
363+ TP_ARGS(dev, wcid, _head, seqno, sn_less),
364+
365+ TP_STRUCT__entry(
366+ DEV_ENTRY
367+ __field(u16, wcid)
368+ __field(u16, _head)
369+ __field(u16, seqno)
370+ __field(bool, sn_less)
371+ ),
372+
373+ TP_fast_assign(
374+ strlcpy(__entry->wiphy_name,
375+ wiphy_name(dev->phys[wcid->phy_idx]->hw->wiphy),
376+ MAXNAME);
377+ __entry->wcid = wcid->idx;
378+ __entry->_head = _head;
379+ __entry->seqno = seqno;
380+ __entry->sn_less = sn_less;
381+ ),
382+
383+ TP_printk(
384+ DEV_PR_FMT " wcid: %u, head: %u, seqno: %u, sn_less: %d",
385+ DEV_PR_ARG, __entry->wcid, __entry->_head, __entry->seqno,
386+ __entry->sn_less
387+ )
388+);
389+
390 #endif
391
392 #undef TRACE_INCLUDE_PATH
393--
developerd0c89452024-10-11 16:53:27 +08003942.45.2
developer05f3b2b2024-08-19 19:17:34 +0800395