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