blob: 406a096c428ebce11ab3810132d6062ca900a50f [file] [log] [blame]
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +01001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2#ifndef _LIBMCTP_CMDS_H
3#define _LIBMCTP_CMDS_H
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#include "libmctp.h"
10
11/*
12 * Helper structs and functions for MCTP control messages.
13 * See DSP0236 v1.3.0 sec. 11 for reference.
14 */
15
16struct mctp_ctrl_msg_hdr {
17 uint8_t ic_msg_type;
18 uint8_t rq_dgram_inst;
19 uint8_t command_code;
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010020};
21
Andrew Jeffery87375382020-06-19 17:20:17 +093022#define MCTP_CTRL_HDR_MSG_TYPE 0
23#define MCTP_CTRL_HDR_FLAG_REQUEST (1 << 7)
24#define MCTP_CTRL_HDR_FLAG_DGRAM (1 << 6)
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010025#define MCTP_CTRL_HDR_INSTANCE_ID_MASK 0x1F
26
27/*
28 * MCTP Control Command IDs
29 * See DSP0236 v1.3.0 Table 12.
30 */
Andrew Jeffery87375382020-06-19 17:20:17 +093031#define MCTP_CTRL_CMD_RESERVED 0x00
32#define MCTP_CTRL_CMD_SET_ENDPOINT_ID 0x01
33#define MCTP_CTRL_CMD_GET_ENDPOINT_ID 0x02
34#define MCTP_CTRL_CMD_GET_ENDPOINT_UUID 0x03
35#define MCTP_CTRL_CMD_GET_VERSION_SUPPORT 0x04
36#define MCTP_CTRL_CMD_GET_MESSAGE_TYPE_SUPPORT 0x05
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010037#define MCTP_CTRL_CMD_GET_VENDOR_MESSAGE_SUPPORT 0x06
Andrew Jeffery87375382020-06-19 17:20:17 +093038#define MCTP_CTRL_CMD_RESOLVE_ENDPOINT_ID 0x07
39#define MCTP_CTRL_CMD_ALLOCATE_ENDPOINT_IDS 0x08
40#define MCTP_CTRL_CMD_ROUTING_INFO_UPDATE 0x09
41#define MCTP_CTRL_CMD_GET_ROUTING_TABLE_ENTRIES 0x0A
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010042#define MCTP_CTRL_CMD_PREPARE_ENDPOINT_DISCOVERY 0x0B
Andrew Jeffery87375382020-06-19 17:20:17 +093043#define MCTP_CTRL_CMD_ENDPOINT_DISCOVERY 0x0C
44#define MCTP_CTRL_CMD_DISCOVERY_NOTIFY 0x0D
45#define MCTP_CTRL_CMD_GET_NETWORK_ID 0x0E
46#define MCTP_CTRL_CMD_QUERY_HOP 0x0F
47#define MCTP_CTRL_CMD_RESOLVE_UUID 0x10
48#define MCTP_CTRL_CMD_QUERY_RATE_LIMIT 0x11
49#define MCTP_CTRL_CMD_REQUEST_TX_RATE_LIMIT 0x12
50#define MCTP_CTRL_CMD_UPDATE_RATE_LIMIT 0x13
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010051#define MCTP_CTRL_CMD_QUERY_SUPPORTED_INTERFACES 0x14
Andrew Jeffery87375382020-06-19 17:20:17 +093052#define MCTP_CTRL_CMD_MAX 0x15
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010053/* 0xF0 - 0xFF are transport specific */
54#define MCTP_CTRL_CMD_FIRST_TRANSPORT 0xF0
Andrew Jeffery87375382020-06-19 17:20:17 +093055#define MCTP_CTRL_CMD_LAST_TRANSPORT 0xFF
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010056
57/*
58 * MCTP Control Completion Codes
59 * See DSP0236 v1.3.0 Table 13.
60 */
Andrew Jeffery87375382020-06-19 17:20:17 +093061#define MCTP_CTRL_CC_SUCCESS 0x00
62#define MCTP_CTRL_CC_ERROR 0x01
63#define MCTP_CTRL_CC_ERROR_INVALID_DATA 0x02
64#define MCTP_CTRL_CC_ERROR_INVALID_LENGTH 0x03
65#define MCTP_CTRL_CC_ERROR_NOT_READY 0x04
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +010066#define MCTP_CTRL_CC_ERROR_UNSUPPORTED_CMD 0x05
67/* 0x80 - 0xFF are command specific */
68
Matt Johnston4058b2c2024-11-07 14:53:50 +080069struct mctp_ctrl_cmd_empty_resp {
70 struct mctp_ctrl_msg_hdr hdr;
71 uint8_t completion_code;
72} __attribute__((packed));
73
74/* Set Endpoint ID request, Operation. Bits [1:0] */
75#define MCTP_CTRL_SET_EID_OP_MASK 0x03
76#define MCTP_CTRL_SET_EID_OP_SET 0x00
77#define MCTP_CTRL_SET_EID_OP_FORCE 0x01
78#define MCTP_CTRL_SET_EID_OP_RESET 0x02
79#define MCTP_CTRL_SET_EID_OP_SET_DISCOVERED 0x03
80
81struct mctp_ctrl_cmd_set_endpoint_id_req {
82 struct mctp_ctrl_msg_hdr hdr;
83 uint8_t operation;
84 uint8_t eid;
85} __attribute__((packed));
86
87/* Set Endpoint ID response, assignment status. Bits [1:0] */
88#define MCTP_CTRL_SET_EID_STATUS_ACCEPTED 0x00
89#define MCTP_CTRL_SET_EID_STATUS_REJECTED 0x01
90
91struct mctp_ctrl_cmd_set_endpoint_id_resp {
92 struct mctp_ctrl_msg_hdr hdr;
93 uint8_t completion_code;
94 uint8_t status;
95 uint8_t eid;
96 uint8_t pool_size;
97} __attribute__((packed));
98
99/* Get Endpoint ID, Endpoint Type. Bits [5:4] */
100#define MCTP_CTRL_ENDPOINT_TYPE_SIMPLE 0x00
101#define MCTP_CTRL_ENDPOINT_TYPE_BUSOWNER_BRIDGE 0x10
102
103/* Get Endpoint ID, Endpoint ID Type. Bits [1:0] */
104#define MCTP_CTRL_ENDPOINT_ID_TYPE_DYNAMIC_ONLY 0x00
105#define MCTP_CTRL_ENDPOINT_ID_TYPE_STATIC 0x01
106#define MCTP_CTRL_ENDPOINT_ID_TYPE_STATIC_SAME 0x02
107#define MCTP_CTRL_ENDPOINT_ID_TYPE_STATIC_DIFFERENT 0x03
108
109struct mctp_ctrl_cmd_get_endpoint_id_resp {
110 struct mctp_ctrl_msg_hdr hdr;
111 uint8_t completion_code;
112 uint8_t endpoint_id;
113 uint8_t endpoint_type;
114 uint8_t medium_specific;
115} __attribute__((packed));
116
117#define MCTP_CTRL_VERSIONS_NOT_SUPPORTED 0x80
118
119struct mctp_ctrl_cmd_get_version_req {
120 struct mctp_ctrl_msg_hdr hdr;
121 uint8_t msg_type;
122} __attribute__((packed));
123
124struct mctp_ctrl_cmd_get_version_resp {
125 struct mctp_ctrl_msg_hdr hdr;
126 uint8_t completion_code;
127 uint8_t version_count;
128 uint32_t versions[];
129} __attribute__((packed));
130
131struct mctp_ctrl_cmd_get_types_resp {
132 struct mctp_ctrl_msg_hdr hdr;
133 uint8_t completion_code;
134 uint8_t type_count;
135 uint8_t types[];
136} __attribute__((packed));
137
Wiktor Gołgowskiba6727e2020-03-13 18:25:01 +0100138#ifdef __cplusplus
139}
140#endif
141
142#endif /* _LIBMCTP_CMDS_H */