OpenBIC
OpenSource Bridge-IC
mctp_ctrl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _MCTP_CTRL_H
18#define _MCTP_CTRL_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "mctp.h"
25#include <stdint.h>
26#include <zephyr.h>
27
28typedef uint8_t (*mctp_ctrl_cmd_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *);
29
30typedef struct _mctp_ctrl_cmd_handler {
31 uint8_t cmd_code;
34
35#define MCTP_BASE_LINE_UNIT 64
36
37#define MCTP_CTRL_CMD_SET_ENDPOINT_ID 0x01
38#define MCTP_CTRL_CMD_GET_ENDPOINT_ID 0x02
39
40#define MCTP_CTRL_CMD_GET_MESSAGE_TYPE_SUPPORT 0x05
41
42#define MCTP_CTRL_CMD_GET_ENDPOINT_ID_REQ_LEN 0x00
43
44#define MCTP_CTRL_READ_STATUS_SUCCESS 0x00
45#define MCTP_CTRL_READ_STATUS_CC_ERROR 0x01
46#define MCTP_CTRL_READ_STATUS_TIMEOUT 0x02
47
48/*
49 * MCTP Control Completion Codes
50 * See DSP0236 v1.3.0 Table 13.
51 */
52#define MCTP_CTRL_CC_SUCCESS 0x00
53#define MCTP_CTRL_CC_ERROR 0x01
54#define MCTP_CTRL_CC_ERROR_INVALID_DATA 0x02
55#define MCTP_CTRL_CC_ERROR_INVALID_LENGTH 0x03
56#define MCTP_CTRL_CC_ERROR_NOT_READY 0x04
57#define MCTP_CTRL_CC_ERROR_UNSUPPORTED_CMD 0x05
58
59#define SET_EID_REQ_OP_SET_EID 0x00
60#define SET_EID_REQ_OP_FORCE_EID 0x01
61
63 uint8_t op;
64 uint8_t eid;
65} __attribute__((packed));
66
69 uint8_t status;
70 uint8_t eid;
72} __attribute__((packed));
73
77};
78
82};
83
84/*
85Reference from DSP0239_1.3.0 Table 1
86*/
91};
92
95 uint8_t type_count;
96 uint8_t type_number[0];
97} __attribute__((packed));
98
101 uint8_t eid;
102 uint8_t eid_type : 2;
103 uint8_t : 2;
104 uint8_t endpoint_type : 2;
105 uint8_t : 2;
107} __attribute__((packed));
108
109typedef struct __attribute__((packed)) {
110 uint8_t msg_type : 7;
111 uint8_t ic : 1;
112
113 union {
114 struct {
115 uint8_t inst_id : 5;
116 uint8_t rsvd : 1;
117 uint8_t d : 1;
118 uint8_t rq : 1;
119 };
120 uint8_t req_d_id;
121 };
122
123 uint8_t cmd;
125
126typedef struct {
128 uint8_t *cmd_data;
129 uint16_t cmd_data_len;
131 void (*recv_resp_cb_fn)(void *, uint8_t *, uint16_t);
133 uint16_t timeout_ms;
134 void (*timeout_cb_fn)(void *);
137
138typedef struct _mctp_ctrl_resp_arg {
139 struct k_msgq *msgq;
140 uint8_t *read_buf;
141 uint16_t read_len;
142 uint16_t return_len;
144
145uint8_t mctp_ctrl_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params);
146
147uint8_t mctp_ctrl_send_msg(void *mctp_p, mctp_ctrl_msg *msg);
148uint8_t mctp_ctrl_read(void *mctp_p, mctp_ctrl_msg *msg, uint8_t *read_buf, uint16_t read_len);
149
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif /* _MCTP_CTRL_H */
uint8_t cmd
Definition: isl69259.c:1
uint8_t eid
Definition: mctp_ctrl.h:1
struct _mctp_ctrl_resp_arg mctp_ctrl_resp_arg
endpoint_type
Definition: mctp_ctrl.h:74
@ SIMPLE_ENDPOINT
Definition: mctp_ctrl.h:75
@ BRIDGE
Definition: mctp_ctrl.h:76
void plat_update_mctp_routing_table(uint8_t eid)
Definition: mctp_ctrl.c:52
message_type
Definition: mctp_ctrl.h:87
@ TYPE_MAX_SIZE
Definition: mctp_ctrl.h:90
@ TYPE_PLDM
Definition: mctp_ctrl.h:89
@ TYPE_MCTP_CONTROL
Definition: mctp_ctrl.h:88
typedef __attribute__
Definition: mctp_ctrl.h:109
uint8_t mctp_ctrl_read(void *mctp_p, mctp_ctrl_msg *msg, uint8_t *read_buf, uint16_t read_len)
Definition: mctp_ctrl.c:423
struct _mctp_ctrl_cmd_handler mctp_ctrl_cmd_handler_t
mctp_ctrl_hdr
Definition: mctp_ctrl.h:124
uint8_t(* mctp_ctrl_cmd_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *)
Definition: mctp_ctrl.h:28
uint8_t mctp_ctrl_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params)
Definition: mctp_ctrl.c:257
uint8_t mctp_ctrl_send_msg(void *mctp_p, mctp_ctrl_msg *msg)
Definition: mctp_ctrl.c:362
eid_type
Definition: mctp_ctrl.h:79
@ DYNAMIC_EID
Definition: mctp_ctrl.h:80
@ STATIC_EID
Definition: mctp_ctrl.h:81
Definition: pldm_smbios.h:61
Definition: mctp_ctrl.h:99
uint8_t medium_specific_info
Definition: mctp_ctrl.h:106
uint8_t eid
Definition: mctp_ctrl.h:101
uint8_t completion_code
Definition: mctp_ctrl.h:100
uint8_t endpoint_type
Definition: mctp_ctrl.h:104
uint8_t eid_type
Definition: mctp_ctrl.h:102
Definition: mctp_ctrl.h:93
uint8_t type_count
Definition: mctp_ctrl.h:95
uint8_t type_number[0]
Definition: mctp_ctrl.h:96
uint8_t completion_code
Definition: mctp_ctrl.h:94
Definition: mctp_ctrl.h:30
uint8_t cmd_code
Definition: mctp_ctrl.h:31
mctp_ctrl_cmd_fn fn
Definition: mctp_ctrl.h:32
Definition: mctp_ctrl.h:138
struct k_msgq * msgq
Definition: mctp_ctrl.h:139
uint16_t read_len
Definition: mctp_ctrl.h:141
uint16_t return_len
Definition: mctp_ctrl.h:142
uint8_t * read_buf
Definition: mctp_ctrl.h:140
Definition: mctp.h:98
Definition: mctp_ctrl.h:62
uint8_t eid
Definition: mctp_ctrl.h:64
uint8_t op
Definition: mctp_ctrl.h:63
Definition: mctp_ctrl.h:67
uint8_t eid_pool_size
Definition: mctp_ctrl.h:71
uint8_t status
Definition: mctp_ctrl.h:69
uint8_t completion_code
Definition: mctp_ctrl.h:68
uint8_t eid
Definition: mctp_ctrl.h:70
Definition: mctp_ctrl.h:126
void * recv_resp_cb_args
Definition: mctp_ctrl.h:132
mctp_ctrl_hdr hdr
Definition: mctp_ctrl.h:127
void * timeout_cb_fn_args
Definition: mctp_ctrl.h:135
uint16_t timeout_ms
Definition: mctp_ctrl.h:133
uint16_t cmd_data_len
Definition: mctp_ctrl.h:129
mctp_ext_params ext_params
Definition: mctp_ctrl.h:130
uint8_t * cmd_data
Definition: mctp_ctrl.h:128
uint8_t rq
Definition: plat_pldm.h:6
uint8_t rsvd
Definition: plat_pldm.h:4
uint8_t d
Definition: plat_pldm.h:5
uint8_t inst_id
Definition: plat_pldm.h:3
uint8_t req_d_id
Definition: plat_pldm.h:8