aboutsummaryrefslogtreecommitdiff
path: root/include/trace_types.h
blob: 54228b92d38d16640cb2105197aeba6ebc65b341 (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
// SPDX-License-Identifier: Apache-2.0
/*
 * API for kernel to read trace buffer.
 *
 * Copyright 2013-2019 IBM Corp.
 */

#ifndef __TRACE_TYPES_H
#define __TRACE_TYPES_H

#include <types.h>

#define TRACE_REPEAT	1
#define TRACE_OVERFLOW	2
#define TRACE_OPAL	3	/* OPAL call */
#define TRACE_FSP_MSG	4	/* FSP message sent/received */
#define TRACE_FSP_EVENT	5	/* FSP driver event */
#define TRACE_UART	6	/* UART driver traces */

/* One per cpu, plus one for NMIs */
struct tracebuf {
	/* Size used to get buffer offset */
	__be64 buf_size;
	/* This where the buffer starts. */
	__be64 start;
	/* This is where writer has written to. */
	__be64 end;
	/* This is where the writer wrote to previously. */
	__be64 last;
	/* Maximum possible size of a record. */
	__be32 max_size;

	char buf[/* TBUF_SZ + max_size */];
};

/* Common header for all trace entries. */
struct trace_hdr {
	__be64 timestamp;
	u8 type;
	u8 len_div_8;
	__be16 cpu;
	u8 unused[4];
};

/* Note: all other entries must be at least as large as this! */
struct trace_repeat {
	__be64 timestamp; /* Last repeat happened at this timestamp */
	u8 type; /* == TRACE_REPEAT */
	u8 len_div_8;
	__be16 cpu;
	__be16 prev_len;
	__be16 num; /* Starts at 1, ie. 1 repeat, or two traces. */
	/* Note that the count can be one short, if read races a repeat. */
};

/* Overflow is special */
struct trace_overflow {
	__be64 unused64; /* Timestamp is unused */
	u8 type; /* == TRACE_OVERFLOW */
	u8 len_div_8;
	u8 unused[6]; /* ie. hdr.cpu is indeterminate */
	__be64 bytes_missed;
};

/* All other trace types have a full header */
struct trace_opal {
	struct trace_hdr hdr;
	__be64 token, lr, sp, r3_to_11[9];
};

#define TRACE_FSP_MSG_IN	0
#define TRACE_FSP_MSG_OUT	1

struct trace_fsp_msg {
	struct trace_hdr hdr;
	__be32 word0;
	__be32 word1;
	u8 dlen;
	u8 dir; /* TRACE_FSP_MSG_IN or TRACE_FSP_MSG_OUT */
	u8 data[56]; /* See dlen, but max is 56 bytes. */
};

#define TRACE_FSP_EVT_LINK_DOWN		0
#define TRACE_FSP_EVT_DISR_CHG		1 /* 0:disr */
#define TRACE_FSP_EVT_SOFT_RR		2 /* 0:disr */
#define TRACE_FSP_EVT_RR_COMPL		3
#define TRACE_FSP_EVT_HDES_CHG		4 /* 0:hdes */
#define TRACE_FSP_EVT_POLL_IRQ		5 /* 0:irq? 1:hdir 2:ctl 3:psi_irq */

struct trace_fsp_event {
	struct trace_hdr hdr;
	__be16 event;
	__be16 fsp_state;
	__be32 data[4]; /* event type specific */
};

#define TRACE_UART_CTX_IRQ		0
#define TRACE_UART_CTX_POLL		1
#define TRACE_UART_CTX_READ		2

struct trace_uart {
	struct trace_hdr hdr;
	u8 ctx;
	u8 cnt;
	u8 irq_state;
	u8 unused;
	__be16 in_count;
};

union trace {
	struct trace_hdr hdr;
	/* Trace types go here... */
	struct trace_repeat repeat;
	struct trace_overflow overflow;
	struct trace_opal opal;
	struct trace_fsp_msg fsp_msg;
	struct trace_fsp_event fsp_evt;
	struct trace_uart uart;
};

#endif /* __TRACE_TYPES_H */