xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/mali_kbase_mipe_proto.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 /* THIS FILE IS AUTOGENERATED BY mali_trace_generator.py.
23  * DO NOT EDIT.
24  */
25 
26 /* clang-format off */
27 
28 #if !defined(_KBASE_MIPE_PROTO_H)
29 #define _KBASE_MIPE_PROTO_H
30 
31 #define _BITFIELD_MASK_FIELD(pos, len) \
32 	(((1u << len) - 1) << pos)
33 
34 #define _BITFIELD_SET_FIELD(pos, len, value) \
35 	(_BITFIELD_MASK_FIELD(pos, len) & (((u32) value) << pos))
36 
37 #define BITFIELD_SET(field_name, value) \
38 	_BITFIELD_SET_FIELD(field_name ## _POS, field_name ## _LEN, value)
39 
40 /* The version of swtrace protocol used in timeline stream. */
41 #define SWTRACE_VERSION    3
42 
43 /* Packet header - first word.
44  * These values must be defined according to MIPE documentation.
45  */
46 #define PACKET_STREAMID_POS  0
47 #define PACKET_STREAMID_LEN  8
48 #define PACKET_RSVD1_POS     (PACKET_STREAMID_POS + PACKET_STREAMID_LEN)
49 #define PACKET_RSVD1_LEN     8
50 #define PACKET_TYPE_POS      (PACKET_RSVD1_POS + PACKET_RSVD1_LEN)
51 #define PACKET_TYPE_LEN      3
52 #define PACKET_CLASS_POS     (PACKET_TYPE_POS + PACKET_TYPE_LEN)
53 #define PACKET_CLASS_LEN     7
54 #define PACKET_FAMILY_POS    (PACKET_CLASS_POS + PACKET_CLASS_LEN)
55 #define PACKET_FAMILY_LEN    6
56 
57 /* Packet header - second word
58  * These values must be defined according to MIPE documentation.
59  */
60 #define PACKET_LENGTH_POS    0
61 #define PACKET_LENGTH_LEN    24
62 #define PACKET_SEQBIT_POS    (PACKET_LENGTH_POS + PACKET_LENGTH_LEN)
63 #define PACKET_SEQBIT_LEN    1
64 #define PACKET_RSVD2_POS     (PACKET_SEQBIT_POS + PACKET_SEQBIT_LEN)
65 #define PACKET_RSVD2_LEN     7
66 
67 /* First word of a MIPE packet */
68 #define MIPE_PACKET_HEADER_W0(pkt_family, pkt_class, pkt_type, stream_id) \
69 	(0                                          \
70 	| BITFIELD_SET(PACKET_FAMILY,   pkt_family) \
71 	| BITFIELD_SET(PACKET_CLASS,    pkt_class)  \
72 	| BITFIELD_SET(PACKET_TYPE,     pkt_type)   \
73 	| BITFIELD_SET(PACKET_STREAMID, stream_id))
74 
75 /* Second word of a MIPE packet */
76 #define MIPE_PACKET_HEADER_W1(packet_length, seqbit) \
77 	(0                                           \
78 	| BITFIELD_SET(PACKET_LENGTH, packet_length) \
79 	| BITFIELD_SET(PACKET_SEQBIT, seqbit))
80 
81 /* The number of bytes reserved for packet header.
82  * These value must be defined according to MIPE documentation.
83  */
84 #define PACKET_HEADER_SIZE 8 /* bytes */
85 
86 /* The number of bytes reserved for packet sequence number.
87  * These value must be defined according to MIPE documentation.
88  */
89 #define PACKET_NUMBER_SIZE 4 /* bytes */
90 
91 /* Timeline packet family ids.
92  * Values are significant! Check MIPE documentation.
93  */
94 enum tl_packet_family {
95 	TL_PACKET_FAMILY_CTRL = 0, /* control packets */
96 	TL_PACKET_FAMILY_TL = 1,   /* timeline packets */
97 	TL_PACKET_FAMILY_COUNT
98 };
99 
100 /* Packet classes used in timeline streams.
101  * Values are significant! Check MIPE documentation.
102  */
103 enum tl_packet_class {
104 	TL_PACKET_CLASS_OBJ = 0, /* timeline objects packet */
105 	TL_PACKET_CLASS_AUX = 1, /* auxiliary events packet */
106 };
107 
108 /* Packet types used in timeline streams.
109  * Values are significant! Check MIPE documentation.
110  */
111 enum tl_packet_type {
112 	TL_PACKET_TYPE_HEADER = 0,  /* stream's header/directory */
113 	TL_PACKET_TYPE_BODY = 1,    /* stream's body */
114 	TL_PACKET_TYPE_SUMMARY = 2, /* stream's summary */
115 };
116 
117 /* Stream ID types (timeline family). */
118 enum tl_stream_id {
119 	TL_STREAM_ID_USER = 0, /* User-space driver Timeline stream. */
120 	TL_STREAM_ID_KERNEL = 1, /* Kernel-space driver Timeline stream. */
121 	TL_STREAM_ID_CSFFW = 2, /* CSF firmware driver Timeline stream. */
122 };
123 
124 #endif /* _KBASE_MIPE_PROTO_H */
125 
126 /* clang-format on */
127