blob: 495622d0ab7dd5552c9b92192e224d3c1f26704a [file] [log] [blame]
From 32f0003ab6551bda92347cad31cd00cc024f88cb Mon Sep 17 00:00:00 2001
From: Shayne Chen <shayne.chen@mediatek.com>
Date: Wed, 7 Sep 2022 12:13:20 +0800
Subject: [PATCH 109/193] mtk: mt76: mt7996: add linux tracing support
Add static tracepoint support for besra.
Change-Id: I3209ba360b49c28e49c7cf464ea130aeba993ef7
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
agg-rx.c | 2 +
mac80211.c | 3 +
mt7996/Makefile | 2 +-
mt7996/mac.c | 6 ++
mt7996/mcu.c | 8 +++
mt7996/mt7996_trace.h | 141 ++++++++++++++++++++++++++++++++++++++++++
mt7996/trace.c | 12 ++++
trace.h | 58 +++++++++++++++++
8 files changed, 231 insertions(+), 1 deletion(-)
create mode 100644 mt7996/mt7996_trace.h
create mode 100644 mt7996/trace.c
diff --git a/agg-rx.c b/agg-rx.c
index 07c386c..b48943c 100644
--- a/agg-rx.c
+++ b/agg-rx.c
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Felix Fietkau <nbd@nbd.name>
*/
#include "mt76.h"
+#include "trace.h"
static unsigned long mt76_aggr_tid_to_timeo(u8 tidno)
{
@@ -187,6 +188,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
seqno = status->seqno;
size = tid->size;
sn_less = ieee80211_sn_less(seqno, head);
+ trace_mt76_rx_aggr_reorder(tid->dev, wcid, head, seqno, sn_less);
if (!tid->started) {
if (sn_less)
diff --git a/mac80211.c b/mac80211.c
index a2b111c..7567446 100644
--- a/mac80211.c
+++ b/mac80211.c
@@ -5,6 +5,7 @@
#include <linux/sched.h>
#include <linux/of.h>
#include "mt76.h"
+#include "trace.h"
static const struct ieee80211_channel mt76_channels_2ghz[] = {
CHAN2G(1, 2412),
@@ -1332,6 +1333,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
mt76_check_ccmp_pn(skb);
skb_shinfo(skb)->frag_list = NULL;
+ trace_mt76_rx_complete(dev, (struct mt76_rx_status *)skb->cb, 0);
mt76_rx_convert(dev, skb, &hw, &sta);
ieee80211_rx_list(hw, sta, skb, &list);
@@ -1341,6 +1343,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
nskb = nskb->next;
skb->next = NULL;
+ trace_mt76_rx_complete(dev, (struct mt76_rx_status *)skb->cb, 1);
mt76_rx_convert(dev, skb, &hw, &sta);
ieee80211_rx_list(hw, sta, skb, &list);
}
diff --git a/mt7996/Makefile b/mt7996/Makefile
index 49ec915..936edc6 100644
--- a/mt7996/Makefile
+++ b/mt7996/Makefile
@@ -12,4 +12,4 @@ mt7996e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \
mt7996e-$(CONFIG_DEV_COREDUMP) += coredump.o
mt7996e-$(CONFIG_NL80211_TESTMODE) += testmode.o
-mt7996e-y += mtk_debugfs.o mtk_mcu.o mtk_debugfs_i.o
+mt7996e-y += mtk_debugfs.o mtk_mcu.o mtk_debugfs_i.o trace.o
diff --git a/mt7996/mac.c b/mt7996/mac.c
index 2e27e3b..1c0d367 100644
--- a/mt7996/mac.c
+++ b/mt7996/mac.c
@@ -11,6 +11,7 @@
#include "mac.h"
#include "mcu.h"
#include "vendor.h"
+#include "mt7996_trace.h"
static const struct mt7996_dfs_radar_spec etsi_radar_specs = {
.pulse_th = { 110, -10, -80, 40, 5200, 128, 5200 },
@@ -344,6 +345,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
phy = mphy->priv;
status->phy_idx = mphy->band_idx;
+ trace_mt7996_fill_rx(phy, skb->data, skb->len);
+
if (!test_bit(MT76_STATE_RUNNING, &mphy->state))
return -EINVAL;
@@ -621,6 +624,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
}
}
+ trace_mt7996_fill_rx_done(phy, status->seqno, hdr_gap);
+
if (!status->wcid || !ieee80211_is_data_qos(fc) || hw_aggr)
return 0;
@@ -1010,6 +1015,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
mt7996_packet_log_to_host(dev, t->skb->data, t->skb->len, PKT_BIN_DEBUG_TX, 0);
mt7996_dump_bmac_txd_info(NULL, dev, (__le32 *)txwi, true, false);
#endif
+ trace_mt7996_tx_prepare(dev, wcid, qid, txwi, t->skb->data, t->skb->len);
return 0;
}
diff --git a/mt7996/mcu.c b/mt7996/mcu.c
index 9b5534d..b6b659d 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -10,6 +10,7 @@
#include "mcu.h"
#include "mac.h"
#include "eeprom.h"
+#include "mt7996_trace.h"
#define fw_name(_dev, name, ...) ({ \
char *_fw; \
@@ -310,6 +311,9 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
else if (cmd & __MCU_CMD_FIELD_WM)
uni_txd->s2d_index = MCU_S2D_H2N;
+ trace_mt7996_mcu_cmd(dev, 1, uni_txd->cid, 0,
+ skb->data, skb->len);
+
goto exit;
}
@@ -337,6 +341,8 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
else
mcu_txd->s2d_index = MCU_S2D_H2N;
+ trace_mt7996_mcu_cmd(dev, 0, mcu_txd->cid, mcu_txd->ext_cid,
+ skb->data, skb->len);
exit:
#ifdef CONFIG_MTK_DEBUG
if (dev->dbg.dump_mcu_pkt)
@@ -1182,6 +1188,8 @@ void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb)
{
struct mt7996_mcu_rxd *rxd = (struct mt7996_mcu_rxd *)skb->data;
+ trace_mt7996_mcu_event(dev, rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT,
+ rxd->eid, rxd->ext_eid, skb->data, skb->len);
if (rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT) {
mt7996_mcu_uni_rx_unsolicited_event(dev, skb);
return;
diff --git a/mt7996/mt7996_trace.h b/mt7996/mt7996_trace.h
new file mode 100644
index 0000000..5fa7348
--- /dev/null
+++ b/mt7996/mt7996_trace.h
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#if !defined(__MT7996_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define __MT7996_TRACE_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include "mt7996.h"
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mt7996
+
+#define MAXNAME 32
+#define DEV_ENTRY __array(char, wiphy_name, 32)
+#define DEV_ASSIGN(_w) strlcpy(__entry->wiphy_name, wiphy_name(_w), MAXNAME)
+#define DEV_PR_FMT "%s"
+#define DEV_PR_ARG __entry->wiphy_name
+
+DECLARE_EVENT_CLASS(mt7996_mcu_debug,
+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
+ const void *data, size_t len),
+ TP_ARGS(dev, uni, id, ext_id, data, len),
+ TP_STRUCT__entry(
+ __field(bool, uni)
+ __field(u8, id)
+ __field(u8, ext_id)
+ __field(size_t, len)
+ __dynamic_array(u8, data, len)
+ ),
+ TP_fast_assign(
+ __entry->uni = uni;
+ __entry->id = id;
+ __entry->ext_id = ext_id;
+ __entry->len = len;
+ memcpy(__get_dynamic_array(data), data, len);
+ ),
+ TP_printk(
+ "uni: %d, id: %u, ext_id: %u, len: %zu",
+ __entry->uni,
+ __entry->id,
+ __entry->ext_id,
+ __entry->len
+ )
+);
+
+DEFINE_EVENT(mt7996_mcu_debug, mt7996_mcu_cmd,
+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
+ const void *data, size_t len),
+ TP_ARGS(dev, uni, id, ext_id, data, len)
+);
+
+DEFINE_EVENT(mt7996_mcu_debug, mt7996_mcu_event,
+ TP_PROTO(struct mt7996_dev *dev, bool uni, u8 id, u8 ext_id,
+ const void *data, size_t len),
+ TP_ARGS(dev, uni, id, ext_id, data, len)
+);
+
+TRACE_EVENT(mt7996_tx_prepare,
+ TP_PROTO(struct mt7996_dev *dev, struct mt76_wcid *wcid, enum mt76_txq_id qid,
+ const void *txwi, const void *data, size_t len),
+ TP_ARGS(dev, wcid, qid, txwi, data, len),
+
+ TP_STRUCT__entry(
+ DEV_ENTRY
+ __field(u16, wcid)
+ __field(u8, qid)
+ __array(u8, txwi, MT_TXD_SIZE)
+ __field(size_t, len)
+ __dynamic_array(u8, data, len)
+ ),
+
+ TP_fast_assign(
+ DEV_ASSIGN(dev->mt76.phys[wcid->phy_idx]->hw->wiphy);
+ __entry->wcid = wcid->idx;
+ __entry->qid = qid;
+ memcpy(__entry->txwi, txwi, MT_TXD_SIZE);
+ __entry->len = len;
+ memcpy(__get_dynamic_array(data), data, len);
+ ),
+
+ TP_printk(
+ DEV_PR_FMT " wcid: %u, qid: %u, len: %zu",
+ DEV_PR_ARG, __entry->wcid, __entry->qid, __entry->len
+ )
+);
+
+TRACE_EVENT(mt7996_fill_rx,
+ TP_PROTO(struct mt7996_phy *phy, const void *data, size_t len),
+ TP_ARGS(phy, data, len),
+
+ TP_STRUCT__entry(
+ DEV_ENTRY
+ __field(size_t, len)
+ __dynamic_array(u8, data, len)
+ ),
+
+ TP_fast_assign(
+ DEV_ASSIGN(phy->mt76->hw->wiphy);
+ __entry->len = len;
+ memcpy(__get_dynamic_array(data), data, len);
+ ),
+
+ TP_printk(
+ DEV_PR_FMT " len: %zu",
+ DEV_PR_ARG, __entry->len
+ )
+);
+
+TRACE_EVENT(mt7996_fill_rx_done,
+ TP_PROTO(struct mt7996_phy *phy, u16 seqno, u16 hdr_gap),
+ TP_ARGS(phy, seqno, hdr_gap),
+
+ TP_STRUCT__entry(
+ DEV_ENTRY
+ __field(u16, seqno)
+ __field(u16, hdr_gap)
+ ),
+
+ TP_fast_assign(
+ DEV_ASSIGN(phy->mt76->hw->wiphy);
+ __entry->seqno = seqno;
+ __entry->hdr_gap = hdr_gap;
+ ),
+
+ TP_printk(
+ DEV_PR_FMT " seqno: %u, hdr_gap: %u",
+ DEV_PR_ARG, __entry->seqno, __entry->hdr_gap
+ )
+);
+
+#endif
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ./mt7996
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE mt7996_trace
+
+#include <trace/define_trace.h>
diff --git a/mt7996/trace.c b/mt7996/trace.c
new file mode 100644
index 0000000..ba36f79
--- /dev/null
+++ b/mt7996/trace.c
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#include <linux/module.h>
+
+#ifndef __CHECKER__
+#define CREATE_TRACE_POINTS
+#include "mt7996_trace.h"
+
+#endif
diff --git a/trace.h b/trace.h
index c3d0ef8..57c94c6 100644
--- a/trace.h
+++ b/trace.h
@@ -101,6 +101,64 @@ DEFINE_EVENT(dev_txid_evt, mac_txdone,
TP_ARGS(dev, wcid, pktid)
);
+TRACE_EVENT(mt76_rx_complete,
+ TP_PROTO(struct mt76_dev *dev, struct mt76_rx_status *status, bool sub),
+ TP_ARGS(dev, status, sub),
+
+ TP_STRUCT__entry(
+ DEV_ENTRY
+ __field(u16, seqno)
+ __field(u16, wcid)
+ __field(u8, first_amsdu)
+ __field(bool, sub)
+ ),
+
+ TP_fast_assign(
+ strlcpy(__entry->wiphy_name,
+ wiphy_name(mt76_dev_phy(dev, status->phy_idx)->hw->wiphy),
+ MAXNAME);
+ __entry->seqno = status->seqno;
+ __entry->wcid = status->wcid ? status->wcid->idx : 0;
+ __entry->first_amsdu = status->first_amsdu;
+ __entry->sub = sub;
+ ),
+
+ TP_printk(
+ DEV_PR_FMT " seqno: %u, wcid: %u, first_amsdu: %x, sub: %d",
+ DEV_PR_ARG, __entry->seqno, __entry->wcid, __entry->first_amsdu,
+ __entry->sub
+ )
+);
+
+TRACE_EVENT(mt76_rx_aggr_reorder,
+ TP_PROTO(struct mt76_dev *dev, struct mt76_wcid *wcid, u16 _head, u16 seqno, bool sn_less),
+ TP_ARGS(dev, wcid, _head, seqno, sn_less),
+
+ TP_STRUCT__entry(
+ DEV_ENTRY
+ __field(u16, wcid)
+ __field(u16, _head)
+ __field(u16, seqno)
+ __field(bool, sn_less)
+ ),
+
+ TP_fast_assign(
+ strlcpy(__entry->wiphy_name,
+ wiphy_name(dev->phys[wcid->phy_idx]->hw->wiphy),
+ MAXNAME);
+ __entry->wcid = wcid->idx;
+ __entry->_head = _head;
+ __entry->seqno = seqno;
+ __entry->sn_less = sn_less;
+ ),
+
+ TP_printk(
+ DEV_PR_FMT " wcid: %u, head: %u, seqno: %u, sn_less: %d",
+ DEV_PR_ARG, __entry->wcid, __entry->_head, __entry->seqno,
+ __entry->sn_less
+ )
+);
+
#endif
#undef TRACE_INCLUDE_PATH
--
2.45.2