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(__MT76x02_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
78c2ecf20Sopenharmony_ci#define __MT76x02_TRACE_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
108c2ecf20Sopenharmony_ci#include "mt76x02.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
138c2ecf20Sopenharmony_ci#define TRACE_SYSTEM mt76x02
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(mt76_hw(dev)->wiphy), MAXNAME)
198c2ecf20Sopenharmony_ci#define DEV_PR_FMT	"%s"
208c2ecf20Sopenharmony_ci#define DEV_PR_ARG	__entry->wiphy_name
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define TXID_ENTRY	__field(u8, wcid) __field(u8, pktid)
238c2ecf20Sopenharmony_ci#define TXID_PR_FMT	" [%d:%d]"
248c2ecf20Sopenharmony_ci#define TXID_PR_ARG	__entry->wcid, __entry->pktid
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(dev_evt,
278c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76x02_dev *dev),
288c2ecf20Sopenharmony_ci	TP_ARGS(dev),
298c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
308c2ecf20Sopenharmony_ci		DEV_ENTRY
318c2ecf20Sopenharmony_ci	),
328c2ecf20Sopenharmony_ci	TP_fast_assign(
338c2ecf20Sopenharmony_ci		DEV_ASSIGN;
348c2ecf20Sopenharmony_ci	),
358c2ecf20Sopenharmony_ci	TP_printk(DEV_PR_FMT, DEV_PR_ARG)
368c2ecf20Sopenharmony_ci);
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciDEFINE_EVENT(dev_evt, mac_txstat_poll,
398c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76x02_dev *dev),
408c2ecf20Sopenharmony_ci	TP_ARGS(dev)
418c2ecf20Sopenharmony_ci);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciTRACE_EVENT(mac_txstat_fetch,
448c2ecf20Sopenharmony_ci	TP_PROTO(struct mt76x02_dev *dev,
458c2ecf20Sopenharmony_ci		 struct mt76x02_tx_status *stat),
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	TP_ARGS(dev, stat),
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
508c2ecf20Sopenharmony_ci		DEV_ENTRY
518c2ecf20Sopenharmony_ci		TXID_ENTRY
528c2ecf20Sopenharmony_ci		__field(bool, success)
538c2ecf20Sopenharmony_ci		__field(bool, aggr)
548c2ecf20Sopenharmony_ci		__field(bool, ack_req)
558c2ecf20Sopenharmony_ci		__field(u16, rate)
568c2ecf20Sopenharmony_ci		__field(u8, retry)
578c2ecf20Sopenharmony_ci	),
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	TP_fast_assign(
608c2ecf20Sopenharmony_ci		DEV_ASSIGN;
618c2ecf20Sopenharmony_ci		__entry->success = stat->success;
628c2ecf20Sopenharmony_ci		__entry->aggr = stat->aggr;
638c2ecf20Sopenharmony_ci		__entry->ack_req = stat->ack_req;
648c2ecf20Sopenharmony_ci		__entry->wcid = stat->wcid;
658c2ecf20Sopenharmony_ci		__entry->pktid = stat->pktid;
668c2ecf20Sopenharmony_ci		__entry->rate = stat->rate;
678c2ecf20Sopenharmony_ci		__entry->retry = stat->retry;
688c2ecf20Sopenharmony_ci	),
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	TP_printk(
718c2ecf20Sopenharmony_ci		DEV_PR_FMT TXID_PR_FMT
728c2ecf20Sopenharmony_ci		" success:%d aggr:%d ack_req:%d"
738c2ecf20Sopenharmony_ci		" rate:%04x retry:%d",
748c2ecf20Sopenharmony_ci		DEV_PR_ARG, TXID_PR_ARG,
758c2ecf20Sopenharmony_ci		__entry->success, __entry->aggr, __entry->ack_req,
768c2ecf20Sopenharmony_ci		__entry->rate, __entry->retry
778c2ecf20Sopenharmony_ci	)
788c2ecf20Sopenharmony_ci);
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#endif
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
838c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH .
848c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
858c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE mt76x02_trace
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
88