summaryrefslogtreecommitdiffstats
path: root/include/trace/events/habanalabs.h
blob: a78d21fa9f2932208053ce8aecf09c7b27a15de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* SPDX-License-Identifier: GPL-2.0
 *
 * Copyright 2022-2023 HabanaLabs, Ltd.
 * All Rights Reserved.
 *
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM habanalabs

#if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HABANALABS_H

#include <linux/tracepoint.h>

DECLARE_EVENT_CLASS(habanalabs_mmu_template,
	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),

	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte),

	TP_STRUCT__entry(
		__string(dname, dev_name(dev))
		__field(u64, virt_addr)
		__field(u64, phys_addr)
		__field(u32, page_size)
		__field(u8, flush_pte)
	),

	TP_fast_assign(
		__assign_str(dname, dev_name(dev));
		__entry->virt_addr = virt_addr;
		__entry->phys_addr = phys_addr;
		__entry->page_size = page_size;
		__entry->flush_pte = flush_pte;
	),

	TP_printk("%s: vaddr: %#llx, paddr: %#llx, psize: %#x, flush: %s",
		__get_str(dname),
		__entry->virt_addr,
		__entry->phys_addr,
		__entry->page_size,
		__entry->flush_pte ? "true" : "false")
);

DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_map,
	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),
	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte));

DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_unmap,
	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),
	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte));

DECLARE_EVENT_CLASS(habanalabs_dma_alloc_template,
	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),

	TP_ARGS(dev, cpu_addr, dma_addr, size, caller),

	TP_STRUCT__entry(
		__string(dname, dev_name(dev))
		__field(u64, cpu_addr)
		__field(u64, dma_addr)
		__field(u32, size)
		__field(const char *, caller)
	),

	TP_fast_assign(
		__assign_str(dname, dev_name(dev));
		__entry->cpu_addr = cpu_addr;
		__entry->dma_addr = dma_addr;
		__entry->size = size;
		__entry->caller = caller;
	),

	TP_printk("%s: cpu_addr: %#llx, dma_addr: %#llx, size: %#x, caller: %s",
		__get_str(dname),
		__entry->cpu_addr,
		__entry->dma_addr,
		__entry->size,
		__entry->caller)
);

DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_alloc,
	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),
	TP_ARGS(dev, cpu_addr, dma_addr, size, caller));

DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_free,
	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),
	TP_ARGS(dev, cpu_addr, dma_addr, size, caller));

DECLARE_EVENT_CLASS(habanalabs_dma_map_template,
	TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len,
			enum dma_data_direction dir, const char *caller),

	TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller),

	TP_STRUCT__entry(
		__string(dname, dev_name(dev))
		__field(u64, phys_addr)
		__field(u64, dma_addr)
		__field(u32, len)
		__field(int, dir)
		__field(const char *, caller)
	),

	TP_fast_assign(
		__assign_str(dname, dev_name(dev));
		__entry->phys_addr = phys_addr;
		__entry->dma_addr = dma_addr;
		__entry->len = len;
		__entry->dir = dir;
		__entry->caller = caller;
	),

	TP_printk("%s: phys_addr: %#llx, dma_addr: %#llx, len: %#x, dir: %d, caller: %s",
		__get_str(dname),
		__entry->phys_addr,
		__entry->dma_addr,
		__entry->len,
		__entry->dir,
		__entry->caller)
);

DEFINE_EVENT(habanalabs_dma_map_template, habanalabs_dma_map_page,
	TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len,
			enum dma_data_direction dir, const char *caller),
	TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller));

DEFINE_EVENT(habanalabs_dma_map_template, habanalabs_dma_unmap_page,
	TP_PROTO(struct device *dev, u64 phys_addr, u64 dma_addr, size_t len,
			enum dma_data_direction dir, const char *caller),
	TP_ARGS(dev, phys_addr, dma_addr, len, dir, caller));

DECLARE_EVENT_CLASS(habanalabs_comms_template,
	TP_PROTO(struct device *dev, char *op_str),

	TP_ARGS(dev, op_str),

	TP_STRUCT__entry(
		__string(dname, dev_name(dev))
		__field(char *, op_str)
	),

	TP_fast_assign(
		__assign_str(dname, dev_name(dev));
		__entry->op_str = op_str;
	),

	TP_printk("%s: cms: %s",
		__get_str(dname),
		__entry->op_str)
);

DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_protocol_cmd,
	TP_PROTO(struct device *dev, char *op_str),
	TP_ARGS(dev, op_str));

DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_send_cmd,
	TP_PROTO(struct device *dev, char *op_str),
	TP_ARGS(dev, op_str));

DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status,
	TP_PROTO(struct device *dev, char *op_str),
	TP_ARGS(dev, op_str));

DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status_done,
	TP_PROTO(struct device *dev, char *op_str),
	TP_ARGS(dev, op_str));

DECLARE_EVENT_CLASS(habanalabs_reg_access_template,
	TP_PROTO(struct device *dev, u32 addr, u32 val),

	TP_ARGS(dev, addr, val),

	TP_STRUCT__entry(
		__string(dname, dev_name(dev))
		__field(u32, addr)
		__field(u32, val)
	),

	TP_fast_assign(
		__assign_str(dname, dev_name(dev));
		__entry->addr = addr;
		__entry->val = val;
	),

	TP_printk("%s: addr: %#x, val: %#x",
		__get_str(dname),
		__entry->addr,
		__entry->val)
);

DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_rreg32,
	TP_PROTO(struct device *dev, u32 addr, u32 val),
	TP_ARGS(dev, addr, val));

DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_wreg32,
	TP_PROTO(struct device *dev, u32 addr, u32 val),
	TP_ARGS(dev, addr, val));

DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_read,
	TP_PROTO(struct device *dev, u32 addr, u32 val),
	TP_ARGS(dev, addr, val));

DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_write,
	TP_PROTO(struct device *dev, u32 addr, u32 val),
	TP_ARGS(dev, addr, val));

#endif /* if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ) */

/* This part must be outside protection */
#include <trace/define_trace.h>