xref: /linux/drivers/gpu/drm/xe/abi/guc_messages_abi.h (revision 1f20a5769446a1acae67ac9e63d07a594829a789)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2014-2021 Intel Corporation
4  */
5 
6 #ifndef _ABI_GUC_MESSAGES_ABI_H
7 #define _ABI_GUC_MESSAGES_ABI_H
8 
9 /**
10  * DOC: HXG Message
11  *
12  * All messages exchanged with GuC are defined using 32 bit dwords.
13  * First dword is treated as a message header. Remaining dwords are optional.
14  *
15  *  +---+-------+--------------------------------------------------------------+
16  *  |   | Bits  | Description                                                  |
17  *  +===+=======+==============================================================+
18  *  |   |       |                                                              |
19  *  | 0 |    31 | **ORIGIN** - originator of the message                       |
20  *  |   |       |   - _`GUC_HXG_ORIGIN_HOST` = 0                               |
21  *  |   |       |   - _`GUC_HXG_ORIGIN_GUC` = 1                                |
22  *  |   |       |                                                              |
23  *  |   +-------+--------------------------------------------------------------+
24  *  |   | 30:28 | **TYPE** - message type                                      |
25  *  |   |       |   - _`GUC_HXG_TYPE_REQUEST` = 0                              |
26  *  |   |       |   - _`GUC_HXG_TYPE_EVENT` = 1                                |
27  *  |   |       |   - _`GUC_HXG_TYPE_FAST_REQUEST` = 2                         |
28  *  |   |       |   - _`GUC_HXG_TYPE_NO_RESPONSE_BUSY` = 3                     |
29  *  |   |       |   - _`GUC_HXG_TYPE_NO_RESPONSE_RETRY` = 5                    |
30  *  |   |       |   - _`GUC_HXG_TYPE_RESPONSE_FAILURE` = 6                     |
31  *  |   |       |   - _`GUC_HXG_TYPE_RESPONSE_SUCCESS` = 7                     |
32  *  |   +-------+--------------------------------------------------------------+
33  *  |   |  27:0 | **AUX** - auxiliary data (depends on TYPE)                   |
34  *  +---+-------+--------------------------------------------------------------+
35  *  | 1 |  31:0 |                                                              |
36  *  +---+-------+                                                              |
37  *  |...|       | **PAYLOAD** - optional payload (depends on TYPE)             |
38  *  +---+-------+                                                              |
39  *  | n |  31:0 |                                                              |
40  *  +---+-------+--------------------------------------------------------------+
41  */
42 
43 #define GUC_HXG_MSG_MIN_LEN			1u
44 #define GUC_HXG_MSG_0_ORIGIN			(0x1u << 31)
45 #define   GUC_HXG_ORIGIN_HOST			0u
46 #define   GUC_HXG_ORIGIN_GUC			1u
47 #define GUC_HXG_MSG_0_TYPE			(0x7u << 28)
48 #define   GUC_HXG_TYPE_REQUEST			0u
49 #define   GUC_HXG_TYPE_EVENT			1u
50 #define   GUC_HXG_TYPE_FAST_REQUEST		2u
51 #define   GUC_HXG_TYPE_NO_RESPONSE_BUSY		3u
52 #define   GUC_HXG_TYPE_NO_RESPONSE_RETRY	5u
53 #define   GUC_HXG_TYPE_RESPONSE_FAILURE		6u
54 #define   GUC_HXG_TYPE_RESPONSE_SUCCESS		7u
55 #define GUC_HXG_MSG_0_AUX			(0xfffffffu << 0)
56 #define GUC_HXG_MSG_n_PAYLOAD			(0xffffffffu << 0)
57 
58 /**
59  * DOC: HXG Request
60  *
61  * The `HXG Request`_ message should be used to initiate synchronous activity
62  * for which confirmation or return data is expected.
63  *
64  * The recipient of this message shall use `HXG Response`_, `HXG Failure`_
65  * or `HXG Retry`_ message as a definite reply, and may use `HXG Busy`_
66  * message as a intermediate reply.
67  *
68  * Format of @DATA0 and all @DATAn fields depends on the @ACTION code.
69  *
70  *  +---+-------+--------------------------------------------------------------+
71  *  |   | Bits  | Description                                                  |
72  *  +===+=======+==============================================================+
73  *  | 0 |    31 | ORIGIN                                                       |
74  *  |   +-------+--------------------------------------------------------------+
75  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_REQUEST_                                 |
76  *  |   +-------+--------------------------------------------------------------+
77  *  |   | 27:16 | **DATA0** - request data (depends on ACTION)                 |
78  *  |   +-------+--------------------------------------------------------------+
79  *  |   |  15:0 | **ACTION** - requested action code                           |
80  *  +---+-------+--------------------------------------------------------------+
81  *  | 1 |  31:0 |                                                              |
82  *  +---+-------+                                                              |
83  *  |...|       | **DATAn** - optional data (depends on ACTION)                |
84  *  +---+-------+                                                              |
85  *  | n |  31:0 |                                                              |
86  *  +---+-------+--------------------------------------------------------------+
87  */
88 
89 #define GUC_HXG_REQUEST_MSG_MIN_LEN		GUC_HXG_MSG_MIN_LEN
90 #define GUC_HXG_REQUEST_MSG_0_DATA0		(0xfffu << 16)
91 #define GUC_HXG_REQUEST_MSG_0_ACTION		(0xffffu << 0)
92 #define GUC_HXG_REQUEST_MSG_n_DATAn		GUC_HXG_MSG_n_PAYLOAD
93 
94 /**
95  * DOC: HXG Event
96  *
97  * The `HXG Event`_ message should be used to initiate asynchronous activity
98  * that does not involves immediate confirmation nor data.
99  *
100  * Format of @DATA0 and all @DATAn fields depends on the @ACTION code.
101  *
102  *  +---+-------+--------------------------------------------------------------+
103  *  |   | Bits  | Description                                                  |
104  *  +===+=======+==============================================================+
105  *  | 0 |    31 | ORIGIN                                                       |
106  *  |   +-------+--------------------------------------------------------------+
107  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_EVENT_                                   |
108  *  |   +-------+--------------------------------------------------------------+
109  *  |   | 27:16 | **DATA0** - event data (depends on ACTION)                   |
110  *  |   +-------+--------------------------------------------------------------+
111  *  |   |  15:0 | **ACTION** - event action code                               |
112  *  +---+-------+--------------------------------------------------------------+
113  *  | 1 |  31:0 |                                                              |
114  *  +---+-------+                                                              |
115  *  |...|       | **DATAn** - optional event  data (depends on ACTION)         |
116  *  +---+-------+                                                              |
117  *  | n |  31:0 |                                                              |
118  *  +---+-------+--------------------------------------------------------------+
119  */
120 
121 #define GUC_HXG_EVENT_MSG_MIN_LEN		GUC_HXG_MSG_MIN_LEN
122 #define GUC_HXG_EVENT_MSG_0_DATA0		(0xfffu << 16)
123 #define GUC_HXG_EVENT_MSG_0_ACTION		(0xffffu << 0)
124 #define GUC_HXG_EVENT_MSG_n_DATAn		GUC_HXG_MSG_n_PAYLOAD
125 
126 /**
127  * DOC: HXG Busy
128  *
129  * The `HXG Busy`_ message may be used to acknowledge reception of the `HXG Request`_
130  * message if the recipient expects that it processing will be longer than default
131  * timeout.
132  *
133  * The @COUNTER field may be used as a progress indicator.
134  *
135  *  +---+-------+--------------------------------------------------------------+
136  *  |   | Bits  | Description                                                  |
137  *  +===+=======+==============================================================+
138  *  | 0 |    31 | ORIGIN                                                       |
139  *  |   +-------+--------------------------------------------------------------+
140  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_NO_RESPONSE_BUSY_                        |
141  *  |   +-------+--------------------------------------------------------------+
142  *  |   |  27:0 | **COUNTER** - progress indicator                             |
143  *  +---+-------+--------------------------------------------------------------+
144  */
145 
146 #define GUC_HXG_BUSY_MSG_LEN			GUC_HXG_MSG_MIN_LEN
147 #define GUC_HXG_BUSY_MSG_0_COUNTER		GUC_HXG_MSG_0_AUX
148 
149 /**
150  * DOC: HXG Retry
151  *
152  * The `HXG Retry`_ message should be used by recipient to indicate that the
153  * `HXG Request`_ message was dropped and it should be resent again.
154  *
155  * The @REASON field may be used to provide additional information.
156  *
157  *  +---+-------+--------------------------------------------------------------+
158  *  |   | Bits  | Description                                                  |
159  *  +===+=======+==============================================================+
160  *  | 0 |    31 | ORIGIN                                                       |
161  *  |   +-------+--------------------------------------------------------------+
162  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_NO_RESPONSE_RETRY_                       |
163  *  |   +-------+--------------------------------------------------------------+
164  *  |   |  27:0 | **REASON** - reason for retry                                |
165  *  |   |       |  - _`GUC_HXG_RETRY_REASON_UNSPECIFIED` = 0                   |
166  *  +---+-------+--------------------------------------------------------------+
167  */
168 
169 #define GUC_HXG_RETRY_MSG_LEN			GUC_HXG_MSG_MIN_LEN
170 #define GUC_HXG_RETRY_MSG_0_REASON		GUC_HXG_MSG_0_AUX
171 #define   GUC_HXG_RETRY_REASON_UNSPECIFIED	0u
172 
173 /**
174  * DOC: HXG Failure
175  *
176  * The `HXG Failure`_ message shall be used as a reply to the `HXG Request`_
177  * message that could not be processed due to an error.
178  *
179  *  +---+-------+--------------------------------------------------------------+
180  *  |   | Bits  | Description                                                  |
181  *  +===+=======+==============================================================+
182  *  | 0 |    31 | ORIGIN                                                       |
183  *  |   +-------+--------------------------------------------------------------+
184  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_RESPONSE_FAILURE_                        |
185  *  |   +-------+--------------------------------------------------------------+
186  *  |   | 27:16 | **HINT** - additional error hint                             |
187  *  |   +-------+--------------------------------------------------------------+
188  *  |   |  15:0 | **ERROR** - error/result code                                |
189  *  +---+-------+--------------------------------------------------------------+
190  */
191 
192 #define GUC_HXG_FAILURE_MSG_LEN			GUC_HXG_MSG_MIN_LEN
193 #define GUC_HXG_FAILURE_MSG_0_HINT		(0xfffu << 16)
194 #define GUC_HXG_FAILURE_MSG_0_ERROR		(0xffffu << 0)
195 
196 /**
197  * DOC: HXG Response
198  *
199  * The `HXG Response`_ message shall be used as a reply to the `HXG Request`_
200  * message that was successfully processed without an error.
201  *
202  *  +---+-------+--------------------------------------------------------------+
203  *  |   | Bits  | Description                                                  |
204  *  +===+=======+==============================================================+
205  *  | 0 |    31 | ORIGIN                                                       |
206  *  |   +-------+--------------------------------------------------------------+
207  *  |   | 30:28 | TYPE = GUC_HXG_TYPE_RESPONSE_SUCCESS_                        |
208  *  |   +-------+--------------------------------------------------------------+
209  *  |   |  27:0 | **DATA0** - data (depends on ACTION from `HXG Request`_)     |
210  *  +---+-------+--------------------------------------------------------------+
211  *  | 1 |  31:0 |                                                              |
212  *  +---+-------+                                                              |
213  *  |...|       | **DATAn** - data (depends on ACTION from `HXG Request`_)     |
214  *  +---+-------+                                                              |
215  *  | n |  31:0 |                                                              |
216  *  +---+-------+--------------------------------------------------------------+
217  */
218 
219 #define GUC_HXG_RESPONSE_MSG_MIN_LEN		GUC_HXG_MSG_MIN_LEN
220 #define GUC_HXG_RESPONSE_MSG_0_DATA0		GUC_HXG_MSG_0_AUX
221 #define GUC_HXG_RESPONSE_MSG_n_DATAn		GUC_HXG_MSG_n_PAYLOAD
222 
223 /* deprecated */
224 #define INTEL_GUC_MSG_TYPE_SHIFT	28
225 #define INTEL_GUC_MSG_TYPE_MASK		(0xF << INTEL_GUC_MSG_TYPE_SHIFT)
226 #define INTEL_GUC_MSG_DATA_SHIFT	16
227 #define INTEL_GUC_MSG_DATA_MASK		(0xFFF << INTEL_GUC_MSG_DATA_SHIFT)
228 #define INTEL_GUC_MSG_CODE_SHIFT	0
229 #define INTEL_GUC_MSG_CODE_MASK		(0xFFFF << INTEL_GUC_MSG_CODE_SHIFT)
230 
231 enum intel_guc_msg_type {
232 	INTEL_GUC_MSG_TYPE_REQUEST = 0x0,
233 	INTEL_GUC_MSG_TYPE_RESPONSE = 0xF,
234 };
235 
236 #endif
237