18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#if !defined(__MT76_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
78c2ecf20Sopenharmony_ci#define __MT76_TRACE_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
108c2ecf20Sopenharmony_ci#include "mt76.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
138c2ecf20Sopenharmony_ci#define TRACE_SYSTEM mt76
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define MAXNAME		32
168c2ecf20Sopenharmony_ci#define DEV_ENTRY	__array(char, wiphy_name, 32)
178c2ecf20Sopenharmony_ci#define DEVICE_ASSIGN	strlcpy(__entry->wiphy_name,	\
188c2ecf20Sopenharmony_ci				wiphy_name(dev->hw->wiphy), MAXNAME)
198c2ecf20Sopenharmony_ci#define DEV_PR_FMT	"%s"
208c2ecf20Sopenharmony_ci#define DEV_PR_ARG	__entry->wiphy_name
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define REG_ENTRY	__field(u32, reg) __field(u32, val)
238c2ecf20Sopenharmony_ci#define REG_ASSIGN	__entry->reg = reg; __entry->val = val
248c2ecf20Sopenharmony_ci#define REG_PR_FMT	" %04x=%08x"
258c2ecf20Sopenharmony_ci#define REG_PR_ARG	__entry->reg, __entry->val
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define TXID_ENTRY	__field(u8, wcid) __field(u8, pktid)
288c2ecf20Sopenharmony_ci#define TXID_ASSIGN	__entry->wcid = wcid; __entry->pktid = pktid
298c2ecf20Sopenharmony_ci#define TXID_PR_FMT	" [%d:%d]"
308c2ecf20Sopenharmony_ci#define TXID_PR_ARG	__entry->wcid, __entry->pktid
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(dev_reg_evt,
338c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
348c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val),
358c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
368c2ecf20Sopenharmony_ci		DEV_ENTRY
378c2ecf20Sopenharmony_ci		REG_ENTRY
388c2ecf20Sopenharmony_ci	),
398c2ecf20Sopenharmony_ci	TP_fast_assign(
408c2ecf20Sopenharmony_ci		DEVICE_ASSIGN;
418c2ecf20Sopenharmony_ci		REG_ASSIGN;
428c2ecf20Sopenharmony_ci	),
438c2ecf20Sopenharmony_ci	TP_printk(
448c2ecf20Sopenharmony_ci		DEV_PR_FMT REG_PR_FMT,
458c2ecf20Sopenharmony_ci		DEV_PR_ARG, REG_PR_ARG
468c2ecf20Sopenharmony_ci	)
478c2ecf20Sopenharmony_ci);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_reg_evt, reg_rr,
508c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
518c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val)
528c2ecf20Sopenharmony_ci);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_reg_evt, reg_wr,
558c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
568c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val)
578c2ecf20Sopenharmony_ci);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciTRACE_EVENT(dev_irq,
608c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 val, u32 mask),
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	TP_ARGS(dev, val, mask),
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
658c2ecf20Sopenharmony_ci		DEV_ENTRY
668c2ecf20Sopenharmony_ci		__field(u32, val)
678c2ecf20Sopenharmony_ci		__field(u32, mask)
688c2ecf20Sopenharmony_ci	),
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	TP_fast_assign(
718c2ecf20Sopenharmony_ci		DEVICE_ASSIGN;
728c2ecf20Sopenharmony_ci		__entry->val = val;
738c2ecf20Sopenharmony_ci		__entry->mask = mask;
748c2ecf20Sopenharmony_ci	),
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	TP_printk(
778c2ecf20Sopenharmony_ci		DEV_PR_FMT " %08x & %08x",
788c2ecf20Sopenharmony_ci		DEV_PR_ARG, __entry->val, __entry->mask
798c2ecf20Sopenharmony_ci	)
808c2ecf20Sopenharmony_ci);
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(dev_txid_evt,
838c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u8 wcid, u8 pktid),
848c2ecf20Sopenharmony_ci	TP_ARGS(dev, wcid, pktid),
858c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
868c2ecf20Sopenharmony_ci		DEV_ENTRY
878c2ecf20Sopenharmony_ci		TXID_ENTRY
888c2ecf20Sopenharmony_ci	),
898c2ecf20Sopenharmony_ci	TP_fast_assign(
908c2ecf20Sopenharmony_ci		DEVICE_ASSIGN;
918c2ecf20Sopenharmony_ci		TXID_ASSIGN;
928c2ecf20Sopenharmony_ci	),
938c2ecf20Sopenharmony_ci	TP_printk(
948c2ecf20Sopenharmony_ci		DEV_PR_FMT TXID_PR_FMT,
958c2ecf20Sopenharmony_ci		DEV_PR_ARG, TXID_PR_ARG
968c2ecf20Sopenharmony_ci	)
978c2ecf20Sopenharmony_ci);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_txid_evt, mac_txdone,
1008c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u8 wcid, u8 pktid),
1018c2ecf20Sopenharmony_ci	TP_ARGS(dev, wcid, pktid)
1028c2ecf20Sopenharmony_ci);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#endif
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
1078c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH .
1088c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
1098c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE trace
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
112