1 /*
2  * Copyright 2018 Advanced Micro Devices, Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef _TA_XGMI_IF_H
25 #define _TA_XGMI_IF_H
26 
27 /* Responses have bit 31 set */
28 #define RSP_ID_MASK (1U << 31)
29 #define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
30 
31 enum ta_command_xgmi {
32 	TA_COMMAND_XGMI__INITIALIZE			= 0x00,
33 	TA_COMMAND_XGMI__GET_NODE_ID			= 0x01,
34 	TA_COMMAND_XGMI__GET_HIVE_ID			= 0x02,
35 	TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO		= 0x03,
36 	TA_COMMAND_XGMI__SET_TOPOLOGY_INFO		= 0x04,
37 	TA_COMMAND_XGMI__GET_PEER_LINKS			= 0x0B
38 };
39 
40 /* XGMI related enumerations */
41 /**********************************************************/;
42 enum ta_xgmi_connected_nodes {
43 	TA_XGMI__MAX_CONNECTED_NODES			= 64
44 };
45 
46 enum ta_xgmi_status {
47 	TA_XGMI_STATUS__SUCCESS				= 0x00,
48 	TA_XGMI_STATUS__GENERIC_FAILURE			= 0x01,
49 	TA_XGMI_STATUS__NULL_POINTER			= 0x02,
50 	TA_XGMI_STATUS__INVALID_PARAMETER		= 0x03,
51 	TA_XGMI_STATUS__NOT_INITIALIZED			= 0x04,
52 	TA_XGMI_STATUS__INVALID_NODE_NUM		= 0x05,
53 	TA_XGMI_STATUS__INVALID_NODE_ID			= 0x06,
54 	TA_XGMI_STATUS__INVALID_TOPOLOGY		= 0x07,
55 	TA_XGMI_STATUS__FAILED_ID_GEN			= 0x08,
56 	TA_XGMI_STATUS__FAILED_TOPOLOGY_INIT		= 0x09,
57 	TA_XGMI_STATUS__SET_SHARING_ERROR		= 0x0A
58 };
59 
60 enum ta_xgmi_assigned_sdma_engine {
61 	TA_XGMI_ASSIGNED_SDMA_ENGINE__NOT_ASSIGNED	= -1,
62 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA0		= 0,
63 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA1		= 1,
64 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA2		= 2,
65 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA3		= 3,
66 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA4		= 4,
67 	TA_XGMI_ASSIGNED_SDMA_ENGINE__SDMA5		= 5
68 };
69 
70 /* input/output structures for XGMI commands */
71 /**********************************************************/
72 struct ta_xgmi_node_info {
73 	uint64_t				node_id;
74 	uint8_t					num_hops;
75 	uint8_t					is_sharing_enabled;
76 	enum ta_xgmi_assigned_sdma_engine	sdma_engine;
77 };
78 
79 struct ta_xgmi_peer_link_info {
80 	uint64_t				node_id;
81 	uint8_t					num_links;
82 };
83 
84 struct ta_xgmi_cmd_initialize_output {
85 	uint32_t	status;
86 };
87 
88 struct ta_xgmi_cmd_get_node_id_output {
89 	uint64_t	node_id;
90 };
91 
92 struct ta_xgmi_cmd_get_hive_id_output {
93 	uint64_t	hive_id;
94 };
95 
96 struct ta_xgmi_cmd_get_topology_info_input {
97 	uint32_t			num_nodes;
98 	struct ta_xgmi_node_info	nodes[TA_XGMI__MAX_CONNECTED_NODES];
99 };
100 
101 struct ta_xgmi_cmd_get_topology_info_output {
102 	uint32_t			num_nodes;
103 	struct ta_xgmi_node_info	nodes[TA_XGMI__MAX_CONNECTED_NODES];
104 };
105 
106 struct ta_xgmi_cmd_get_peer_link_info_output {
107 	uint32_t			num_nodes;
108 	struct ta_xgmi_peer_link_info	nodes[TA_XGMI__MAX_CONNECTED_NODES];
109 };
110 
111 struct ta_xgmi_cmd_set_topology_info_input {
112 	uint32_t			num_nodes;
113 	struct ta_xgmi_node_info	nodes[TA_XGMI__MAX_CONNECTED_NODES];
114 };
115 
116 /**********************************************************/
117 /* Common input structure for XGMI callbacks */
118 union ta_xgmi_cmd_input {
119 	struct ta_xgmi_cmd_get_topology_info_input	get_topology_info;
120 	struct ta_xgmi_cmd_set_topology_info_input	set_topology_info;
121 };
122 
123 /* Common output structure for XGMI callbacks */
124 union ta_xgmi_cmd_output {
125 	struct ta_xgmi_cmd_initialize_output		initialize;
126 	struct ta_xgmi_cmd_get_node_id_output		get_node_id;
127 	struct ta_xgmi_cmd_get_hive_id_output		get_hive_id;
128 	struct ta_xgmi_cmd_get_topology_info_output	get_topology_info;
129 	struct ta_xgmi_cmd_get_peer_link_info_output	get_link_info;
130 };
131 /**********************************************************/
132 
133 struct ta_xgmi_shared_memory {
134 	uint32_t			cmd_id;
135 	uint32_t			resp_id;
136 	enum ta_xgmi_status		xgmi_status;
137 	uint8_t				flag_extend_link_record;
138 	uint8_t				reserved0[3];
139 	union ta_xgmi_cmd_input		xgmi_in_message;
140 	union ta_xgmi_cmd_output	xgmi_out_message;
141 };
142 
143 #endif   //_TA_XGMI_IF_H
144