133965Sjdp/* SPDX-License-Identifier: GPL-2.0-only */
2130561Sobrien/*
3218822Sdim * amdtp-motu-trace.h - tracepoint definitions to dump a part of packet data
433965Sjdp *
5218822Sdim * Copyright (c) 2017 Takashi Sakamoto
633965Sjdp */
7218822Sdim
8218822Sdim#undef TRACE_SYSTEM
9218822Sdim#define TRACE_SYSTEM		snd_firewire_motu
10218822Sdim
1133965Sjdp#if !defined(_SND_FIREWIRE_MOTU_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12218822Sdim#define _SND_FIREWIRE_MOTU_TRACE_H
13218822Sdim
14218822Sdim#include <linux/tracepoint.h>
15218822Sdim
1633965Sjdpstatic void copy_sph(u32 *frame, __be32 *buffer, unsigned int data_blocks,
17218822Sdim		     unsigned int data_block_quadlets);
18218822Sdimstatic void copy_message(u64 *frames, __be32 *buffer, unsigned int data_blocks,
19218822Sdim			 unsigned int data_block_quadlets);
20218822Sdim
2133965SjdpTRACE_EVENT(data_block_sph,
2260484Sobrien	TP_PROTO(struct amdtp_stream *s, unsigned int data_blocks, __be32 *buffer),
2360484Sobrien	TP_ARGS(s, data_blocks, buffer),
2433965Sjdp	TP_STRUCT__entry(
2533965Sjdp		__field(int, src)
2633965Sjdp		__field(int, dst)
2733965Sjdp		__field(unsigned int, data_blocks)
2833965Sjdp		__dynamic_array(u32, tstamps, data_blocks)
2933965Sjdp	),
30218822Sdim	TP_fast_assign(
3133965Sjdp		if (s->direction == AMDTP_IN_STREAM) {
3233965Sjdp			__entry->src = fw_parent_device(s->unit)->node_id;
3333965Sjdp			__entry->dst = fw_parent_device(s->unit)->card->node_id;
3433965Sjdp		} else {
3533965Sjdp			__entry->src = fw_parent_device(s->unit)->card->node_id;
3660484Sobrien			__entry->dst = fw_parent_device(s->unit)->node_id;
3760484Sobrien		}
3860484Sobrien		__entry->data_blocks = data_blocks;
3960484Sobrien		copy_sph(__get_dynamic_array(tstamps), buffer, data_blocks, s->data_block_quadlets);
4060484Sobrien	),
4133965Sjdp	TP_printk(
4233965Sjdp		"%04x %04x %u %s",
4333965Sjdp		__entry->src,
4433965Sjdp		__entry->dst,
4533965Sjdp		__entry->data_blocks,
4633965Sjdp		__print_array(__get_dynamic_array(tstamps), __entry->data_blocks, 4)
4760484Sobrien	)
4860484Sobrien);
4960484Sobrien
5060484SobrienTRACE_EVENT(data_block_message,
5133965Sjdp	TP_PROTO(struct amdtp_stream *s, unsigned int data_blocks, __be32 *buffer),
5233965Sjdp	TP_ARGS(s, data_blocks, buffer),
5333965Sjdp	TP_STRUCT__entry(
5433965Sjdp		__field(int, src)
5533965Sjdp		__field(int, dst)
5633965Sjdp		__field(unsigned int, data_blocks)
5733965Sjdp		__dynamic_array(u64, messages, data_blocks)
5833965Sjdp	),
5933965Sjdp	TP_fast_assign(
6033965Sjdp		if (s->direction == AMDTP_IN_STREAM) {
6133965Sjdp			__entry->src = fw_parent_device(s->unit)->node_id;
6233965Sjdp			__entry->dst = fw_parent_device(s->unit)->card->node_id;
6333965Sjdp		} else {
6433965Sjdp			__entry->src = fw_parent_device(s->unit)->card->node_id;
6533965Sjdp			__entry->dst = fw_parent_device(s->unit)->node_id;
6633965Sjdp		}
6733965Sjdp		__entry->data_blocks = data_blocks;
6833965Sjdp		copy_message(__get_dynamic_array(messages), buffer, data_blocks, s->data_block_quadlets);
6933965Sjdp	),
7033965Sjdp	TP_printk(
7133965Sjdp		"%04x %04x %u %s",
7260484Sobrien		__entry->src,
7333965Sjdp		__entry->dst,
7433965Sjdp		__entry->data_blocks,
7533965Sjdp		__print_array(__get_dynamic_array(messages), __entry->data_blocks, 8)
7633965Sjdp	)
7733965Sjdp);
7833965Sjdp
7933965Sjdp#endif
8033965Sjdp
8133965Sjdp#undef TRACE_INCLUDE_PATH
8233965Sjdp#define TRACE_INCLUDE_PATH	.
8333965Sjdp#undef TRACE_INCLUDE_FILE
8433965Sjdp#define TRACE_INCLUDE_FILE	amdtp-motu-trace
8560484Sobrien#include <trace/define_trace.h>
8633965Sjdp