18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: ISC */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#if !defined(__MT76_USB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
78c2ecf20Sopenharmony_ci#define __MT76_USB_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_usb
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define MAXNAME		32
168c2ecf20Sopenharmony_ci#define DEV_ENTRY	__array(char, wiphy_name, 32)
178c2ecf20Sopenharmony_ci#define DEV_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	"reg:0x%04x=0x%08x"
258c2ecf20Sopenharmony_ci#define REG_PR_ARG	__entry->reg, __entry->val
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(dev_reg_evt,
288c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
298c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val),
308c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
318c2ecf20Sopenharmony_ci		DEV_ENTRY
328c2ecf20Sopenharmony_ci		REG_ENTRY
338c2ecf20Sopenharmony_ci	),
348c2ecf20Sopenharmony_ci	TP_fast_assign(
358c2ecf20Sopenharmony_ci		DEV_ASSIGN;
368c2ecf20Sopenharmony_ci		REG_ASSIGN;
378c2ecf20Sopenharmony_ci	),
388c2ecf20Sopenharmony_ci	TP_printk(
398c2ecf20Sopenharmony_ci		DEV_PR_FMT REG_PR_FMT,
408c2ecf20Sopenharmony_ci		DEV_PR_ARG, REG_PR_ARG
418c2ecf20Sopenharmony_ci	)
428c2ecf20Sopenharmony_ci);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_reg_evt, usb_reg_rr,
458c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
468c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val)
478c2ecf20Sopenharmony_ci);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_reg_evt, usb_reg_wr,
508c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, u32 reg, u32 val),
518c2ecf20Sopenharmony_ci	TP_ARGS(dev, reg, val)
528c2ecf20Sopenharmony_ci);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(urb_transfer,
558c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, struct urb *u),
568c2ecf20Sopenharmony_ci	TP_ARGS(dev, u),
578c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
588c2ecf20Sopenharmony_ci		DEV_ENTRY __field(unsigned int, pipe) __field(u32, len)
598c2ecf20Sopenharmony_ci	),
608c2ecf20Sopenharmony_ci	TP_fast_assign(
618c2ecf20Sopenharmony_ci		DEV_ASSIGN;
628c2ecf20Sopenharmony_ci		__entry->pipe = u->pipe;
638c2ecf20Sopenharmony_ci		__entry->len = u->transfer_buffer_length;
648c2ecf20Sopenharmony_ci	),
658c2ecf20Sopenharmony_ci	TP_printk(DEV_PR_FMT "p:%08x len:%u",
668c2ecf20Sopenharmony_ci		  DEV_PR_ARG, __entry->pipe, __entry->len)
678c2ecf20Sopenharmony_ci);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciDEFINE_EVENT(urb_transfer, submit_urb,
708c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, struct urb *u),
718c2ecf20Sopenharmony_ci	TP_ARGS(dev, u)
728c2ecf20Sopenharmony_ci);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciDEFINE_EVENT(urb_transfer, rx_urb,
758c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76_dev *dev, struct urb *u),
768c2ecf20Sopenharmony_ci	TP_ARGS(dev, u)
778c2ecf20Sopenharmony_ci);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#endif
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
828c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH .
838c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
848c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE usb_trace
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
87