xref: /linux/drivers/gpu/drm/xe/abi/guc_communication_ctb_abi.h (revision 7f4f3b14e8079ecde096bd734af10e30d40c27b7)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2014-2021 Intel Corporation
4  */
5 
6 #ifndef _ABI_GUC_COMMUNICATION_CTB_ABI_H
7 #define _ABI_GUC_COMMUNICATION_CTB_ABI_H
8 
9 #include <linux/types.h>
10 #include <linux/build_bug.h>
11 
12 #include "guc_messages_abi.h"
13 
14 /**
15  * DOC: CT Buffer
16  *
17  * Circular buffer used to send `CTB Message`_
18  */
19 
20 /**
21  * DOC: CTB Descriptor
22  *
23  *  +---+-------+--------------------------------------------------------------+
24  *  |   | Bits  | Description                                                  |
25  *  +===+=======+==============================================================+
26  *  | 0 |  31:0 | **HEAD** - offset (in dwords) to the last dword that was     |
27  *  |   |       | read from the `CT Buffer`_.                                  |
28  *  |   |       | It can only be updated by the receiver.                      |
29  *  +---+-------+--------------------------------------------------------------+
30  *  | 1 |  31:0 | **TAIL** - offset (in dwords) to the last dword that was     |
31  *  |   |       | written to the `CT Buffer`_.                                 |
32  *  |   |       | It can only be updated by the sender.                        |
33  *  +---+-------+--------------------------------------------------------------+
34  *  | 2 |  31:0 | **STATUS** - status of the CTB                               |
35  *  |   |       |                                                              |
36  *  |   |       |   - _`GUC_CTB_STATUS_NO_ERROR` = 0 (normal operation)        |
37  *  |   |       |   - _`GUC_CTB_STATUS_OVERFLOW` = 1 (head/tail too large)     |
38  *  |   |       |   - _`GUC_CTB_STATUS_UNDERFLOW` = 2 (truncated message)      |
39  *  |   |       |   - _`GUC_CTB_STATUS_MISMATCH` = 4 (head/tail modified)      |
40  *  +---+-------+--------------------------------------------------------------+
41  *  |...|       | RESERVED = MBZ                                               |
42  *  +---+-------+--------------------------------------------------------------+
43  *  | 15|  31:0 | RESERVED = MBZ                                               |
44  *  +---+-------+--------------------------------------------------------------+
45  */
46 
47 struct guc_ct_buffer_desc {
48 	u32 head;
49 	u32 tail;
50 	u32 status;
51 #define GUC_CTB_STATUS_NO_ERROR				0
52 #define GUC_CTB_STATUS_OVERFLOW				(1 << 0)
53 #define GUC_CTB_STATUS_UNDERFLOW			(1 << 1)
54 #define GUC_CTB_STATUS_MISMATCH				(1 << 2)
55 #define GUC_CTB_STATUS_DISABLED				(1 << 3)
56 	u32 reserved[13];
57 } __packed;
58 static_assert(sizeof(struct guc_ct_buffer_desc) == 64);
59 
60 /**
61  * DOC: CTB Message
62  *
63  *  +---+-------+--------------------------------------------------------------+
64  *  |   | Bits  | Description                                                  |
65  *  +===+=======+==============================================================+
66  *  | 0 | 31:16 | **FENCE** - message identifier                               |
67  *  |   +-------+--------------------------------------------------------------+
68  *  |   | 15:12 | **FORMAT** - format of the CTB message                       |
69  *  |   |       |  - _`GUC_CTB_FORMAT_HXG` = 0 - see `CTB HXG Message`_        |
70  *  |   +-------+--------------------------------------------------------------+
71  *  |   |  11:8 | **RESERVED**                                                 |
72  *  |   +-------+--------------------------------------------------------------+
73  *  |   |   7:0 | **NUM_DWORDS** - length of the CTB message (w/o header)      |
74  *  +---+-------+--------------------------------------------------------------+
75  *  | 1 |  31:0 | optional (depends on FORMAT)                                 |
76  *  +---+-------+                                                              |
77  *  |...|       |                                                              |
78  *  +---+-------+                                                              |
79  *  | n |  31:0 |                                                              |
80  *  +---+-------+--------------------------------------------------------------+
81  */
82 
83 #define GUC_CTB_HDR_LEN				1u
84 #define GUC_CTB_MSG_MIN_LEN			GUC_CTB_HDR_LEN
85 #define GUC_CTB_MSG_MAX_LEN			(GUC_CTB_MSG_MIN_LEN + GUC_CTB_MAX_DWORDS)
86 #define GUC_CTB_MSG_0_FENCE			(0xffffu << 16)
87 #define GUC_CTB_MSG_0_FORMAT			(0xfu << 12)
88 #define   GUC_CTB_FORMAT_HXG			0u
89 #define GUC_CTB_MSG_0_RESERVED			(0xfu << 8)
90 #define GUC_CTB_MSG_0_NUM_DWORDS		(0xffu << 0)
91 #define   GUC_CTB_MAX_DWORDS			255
92 
93 /**
94  * DOC: CTB HXG Message
95  *
96  *  +---+-------+--------------------------------------------------------------+
97  *  |   | Bits  | Description                                                  |
98  *  +===+=======+==============================================================+
99  *  | 0 | 31:16 | FENCE                                                        |
100  *  |   +-------+--------------------------------------------------------------+
101  *  |   | 15:12 | FORMAT = GUC_CTB_FORMAT_HXG_                                 |
102  *  |   +-------+--------------------------------------------------------------+
103  *  |   |  11:8 | RESERVED = MBZ                                               |
104  *  |   +-------+--------------------------------------------------------------+
105  *  |   |   7:0 | NUM_DWORDS = length (in dwords) of the embedded HXG message  |
106  *  +---+-------+--------------------------------------------------------------+
107  *  | 1 |  31:0 |                                                              |
108  *  +---+-------+                                                              |
109  *  |...|       | [Embedded `HXG Message`_]                                    |
110  *  +---+-------+                                                              |
111  *  | n |  31:0 |                                                              |
112  *  +---+-------+--------------------------------------------------------------+
113  */
114 
115 #define GUC_CTB_HXG_MSG_MIN_LEN		(GUC_CTB_MSG_MIN_LEN + GUC_HXG_MSG_MIN_LEN)
116 #define GUC_CTB_HXG_MSG_MAX_LEN		GUC_CTB_MSG_MAX_LEN
117 
118 /**
119  * DOC: CTB based communication
120  *
121  * The CTB (command transport buffer) communication between Host and GuC
122  * is based on u32 data stream written to the shared buffer. One buffer can
123  * be used to transmit data only in one direction (one-directional channel).
124  *
125  * Current status of the each buffer is maintained in the `CTB Descriptor`_.
126  * Each message in data stream is encoded as `CTB HXG Message`_.
127  */
128 
129 #endif
130