2 * Copyright © 2011-2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Jike Song <jike.song@intel.com>
27 * Zhi Wang <zhi.a.wang@intel.com>
31 #if !defined(_GVT_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
34 #include <linux/types.h>
35 #include <linux/stringify.h>
36 #include <linux/tracepoint.h>
40 #define TRACE_SYSTEM gvt
42 TRACE_EVENT(spt_alloc
,
43 TP_PROTO(int id
, void *spt
, int type
, unsigned long mfn
,
44 unsigned long gpt_gfn
),
46 TP_ARGS(id
, spt
, type
, mfn
, gpt_gfn
),
52 __field(unsigned long, mfn
)
53 __field(unsigned long, gpt_gfn
)
61 __entry
->gpt_gfn
= gpt_gfn
;
64 TP_printk("VM%d [alloc] spt %p type %d mfn 0x%lx gfn 0x%lx\n",
73 TP_PROTO(int id
, void *spt
, int type
),
75 TP_ARGS(id
, spt
, type
),
89 TP_printk("VM%u [free] spt %p type %d\n",
95 #define MAX_BUF_LEN 256
97 TRACE_EVENT(gma_index
,
98 TP_PROTO(const char *prefix
, unsigned long gma
,
101 TP_ARGS(prefix
, gma
, index
),
104 __array(char, buf
, MAX_BUF_LEN
)
108 snprintf(__entry
->buf
, MAX_BUF_LEN
,
109 "%s gma 0x%lx index 0x%lx\n", prefix
, gma
, index
);
112 TP_printk("%s", __entry
->buf
)
115 TRACE_EVENT(gma_translate
,
116 TP_PROTO(int id
, char *type
, int ring_id
, int pt_level
,
117 unsigned long gma
, unsigned long gpa
),
119 TP_ARGS(id
, type
, ring_id
, pt_level
, gma
, gpa
),
122 __array(char, buf
, MAX_BUF_LEN
)
126 snprintf(__entry
->buf
, MAX_BUF_LEN
,
127 "VM%d %s ring %d pt_level %d gma 0x%lx -> gpa 0x%lx\n",
128 id
, type
, ring_id
, pt_level
, gma
, gpa
);
131 TP_printk("%s", __entry
->buf
)
134 TRACE_EVENT(spt_refcount
,
135 TP_PROTO(int id
, char *action
, void *spt
, int before
, int after
),
137 TP_ARGS(id
, action
, spt
, before
, after
),
140 __array(char, buf
, MAX_BUF_LEN
)
144 snprintf(__entry
->buf
, MAX_BUF_LEN
,
145 "VM%d [%s] spt %p before %d -> after %d\n",
146 id
, action
, spt
, before
, after
);
149 TP_printk("%s", __entry
->buf
)
152 TRACE_EVENT(spt_change
,
153 TP_PROTO(int id
, char *action
, void *spt
, unsigned long gfn
,
156 TP_ARGS(id
, action
, spt
, gfn
, type
),
159 __array(char, buf
, MAX_BUF_LEN
)
163 snprintf(__entry
->buf
, MAX_BUF_LEN
,
164 "VM%d [%s] spt %p gfn 0x%lx type %d\n",
165 id
, action
, spt
, gfn
, type
);
168 TP_printk("%s", __entry
->buf
)
171 TRACE_EVENT(gpt_change
,
172 TP_PROTO(int id
, const char *tag
, void *spt
, int type
, u64 v
,
173 unsigned long index
),
175 TP_ARGS(id
, tag
, spt
, type
, v
, index
),
178 __array(char, buf
, MAX_BUF_LEN
)
182 snprintf(__entry
->buf
, MAX_BUF_LEN
,
183 "VM%d [%s] spt %p type %d entry 0x%llx index 0x%lx\n",
184 id
, tag
, spt
, type
, v
, index
);
187 TP_printk("%s", __entry
->buf
)
190 TRACE_EVENT(oos_change
,
191 TP_PROTO(int id
, const char *tag
, int page_id
, void *gpt
, int type
),
193 TP_ARGS(id
, tag
, page_id
, gpt
, type
),
196 __array(char, buf
, MAX_BUF_LEN
)
200 snprintf(__entry
->buf
, MAX_BUF_LEN
,
201 "VM%d [oos %s] page id %d gpt %p type %d\n",
202 id
, tag
, page_id
, gpt
, type
);
205 TP_printk("%s", __entry
->buf
)
208 TRACE_EVENT(oos_sync
,
209 TP_PROTO(int id
, int page_id
, void *gpt
, int type
, u64 v
,
210 unsigned long index
),
212 TP_ARGS(id
, page_id
, gpt
, type
, v
, index
),
215 __array(char, buf
, MAX_BUF_LEN
)
219 snprintf(__entry
->buf
, MAX_BUF_LEN
,
220 "VM%d [oos sync] page id %d gpt %p type %d entry 0x%llx index 0x%lx\n",
221 id
, page_id
, gpt
, type
, v
, index
);
224 TP_printk("%s", __entry
->buf
)
227 TRACE_EVENT(gvt_command
,
228 TP_PROTO(u8 vgpu_id
, u8 ring_id
, u32 ip_gma
, u32
*cmd_va
, u32 cmd_len
,
231 TP_ARGS(vgpu_id
, ring_id
, ip_gma
, cmd_va
, cmd_len
, buf_type
),
237 __field(u32
, buf_type
)
238 __field(u32
, cmd_len
)
239 __dynamic_array(u32
, raw_cmd
, cmd_len
)
243 __entry
->vgpu_id
= vgpu_id
;
244 __entry
->ring_id
= ring_id
;
245 __entry
->ip_gma
= ip_gma
;
246 __entry
->buf_type
= buf_type
;
247 __entry
->cmd_len
= cmd_len
;
248 memcpy(__get_dynamic_array(raw_cmd
), cmd_va
, cmd_len
* sizeof(*cmd_va
));
252 TP_printk("vgpu%d ring %d: buf_type %u, ip_gma %08x, raw cmd %s",
257 __print_array(__get_dynamic_array(raw_cmd
), __entry
->cmd_len
, 4))
260 #define GVT_TEMP_STR_LEN 10
261 TRACE_EVENT(write_ir
,
262 TP_PROTO(int id
, char *reg_name
, unsigned int reg
, unsigned int new_val
,
263 unsigned int old_val
, bool changed
),
265 TP_ARGS(id
, reg_name
, reg
, new_val
, old_val
, changed
),
269 __array(char, buf
, GVT_TEMP_STR_LEN
)
270 __field(unsigned int, reg
)
271 __field(unsigned int, new_val
)
272 __field(unsigned int, old_val
)
273 __field(bool, changed
)
278 snprintf(__entry
->buf
, GVT_TEMP_STR_LEN
, "%s", reg_name
);
280 __entry
->new_val
= new_val
;
281 __entry
->old_val
= old_val
;
282 __entry
->changed
= changed
;
285 TP_printk("VM%u write [%s] %x, new %08x, old %08x, changed %08x\n",
286 __entry
->id
, __entry
->buf
, __entry
->reg
, __entry
->new_val
,
287 __entry
->old_val
, __entry
->changed
)
290 TRACE_EVENT(propagate_event
,
291 TP_PROTO(int id
, const char *irq_name
, int bit
),
293 TP_ARGS(id
, irq_name
, bit
),
297 __array(char, buf
, GVT_TEMP_STR_LEN
)
303 snprintf(__entry
->buf
, GVT_TEMP_STR_LEN
, "%s", irq_name
);
307 TP_printk("Set bit (%d) for (%s) for vgpu (%d)\n",
308 __entry
->bit
, __entry
->buf
, __entry
->id
)
311 TRACE_EVENT(inject_msi
,
312 TP_PROTO(int id
, unsigned int address
, unsigned int data
),
314 TP_ARGS(id
, address
, data
),
318 __field(unsigned int, address
)
319 __field(unsigned int, data
)
324 __entry
->address
= address
;
325 __entry
->data
= data
;
328 TP_printk("vgpu%d:inject msi address %x data %x\n",
329 __entry
->id
, __entry
->address
, __entry
->data
)
332 TRACE_EVENT(render_mmio
,
333 TP_PROTO(int old_id
, int new_id
, char *action
, unsigned int reg
,
334 unsigned int old_val
, unsigned int new_val
),
336 TP_ARGS(old_id
, new_id
, action
, reg
, old_val
, new_val
),
341 __array(char, buf
, GVT_TEMP_STR_LEN
)
342 __field(unsigned int, reg
)
343 __field(unsigned int, old_val
)
344 __field(unsigned int, new_val
)
348 __entry
->old_id
= old_id
;
349 __entry
->new_id
= new_id
;
350 snprintf(__entry
->buf
, GVT_TEMP_STR_LEN
, "%s", action
);
352 __entry
->old_val
= old_val
;
353 __entry
->new_val
= new_val
;
356 TP_printk("VM%u -> VM%u %s reg %x, old %08x new %08x\n",
357 __entry
->old_id
, __entry
->new_id
,
358 __entry
->buf
, __entry
->reg
,
359 __entry
->old_val
, __entry
->new_val
)
362 #endif /* _GVT_TRACE_H_ */
364 /* This part must be out of protection */
365 #undef TRACE_INCLUDE_PATH
366 #define TRACE_INCLUDE_PATH .
367 #undef TRACE_INCLUDE_FILE
368 #define TRACE_INCLUDE_FILE trace
369 #include <trace/define_trace.h>