OpenBIC
OpenSource Bridge-IC
cci.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 _CCI_H
18#define _CCI_H
19#include "mctp.h"
20
21typedef enum {
26} CCI_CMD;
27
28/*CCI Request paypload length */
29#define HEALTH_INFO_REQ_PL_LEN 0 /*Size Bytes*/
30#define GET_FW_INFO_REQ_PL_LEN 0
31#define TRANSFER_FW_REQ_PL_LEN 256
32#define ACTIVATE_FW_REQ_PL_LEN 2
33
34/*CCI Response paypload length */
35#define HEALTH_INFO_RESP_PL_LEN 18 /*Size Bytes*/
36#define GET_FW_INFO_RESP_PL_LEN 80
37#define TRANSFER_FW_RESP_PL_LEN 0
38#define ACTIVATE_FW_RESP_PL_LEN 0
39
40#define GET_FW_INFO_RESV_LEN 13
41#define GET_FW_INFO_REVISION_LEN 16
42#define TRANSFER_FW_RESV_LEN 120
43#define TRANSFER_FW_DATA_LEN 128
44
47 void (*handler_query)(uint8_t *, uint16_t);
48};
49
50typedef struct _cci_recv_resp_arg {
51 struct k_msgq *msgq;
52 uint8_t *rbuf;
53 uint16_t rbuf_len;
54 uint16_t return_len;
56
57typedef struct __attribute__((packed)) {
58 uint8_t msg_type : 7;
59 uint8_t ic : 1;
60 uint8_t cci_msg_req_resp; /* 0h = Request, 1h = Response*/
61 uint8_t msg_tag;
62 uint8_t cci_rsv;
63 uint16_t op;
64 int pl_len : 21;
65 uint8_t rsv : 2;
66 uint8_t BO : 1;
67 uint16_t ret;
68 uint16_t stat;
70
71typedef struct {
73 uint8_t *pl_data;
75 void (*recv_resp_cb_fn)(void *, uint8_t *, uint16_t, uint16_t);
77 uint16_t timeout_ms;
78 void (*timeout_cb_fn)(void *);
81
82typedef uint8_t (*mctp_cci_cmd_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *);
83typedef uint8_t (*cci_cmd_proc_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *);
84
85typedef struct _mctp_cci_cmd_handler {
86 uint8_t cmd_code;
89
90#define DEV_TEMP_OFFSET 16
91#define CCI_CC_INVALID_INPUT 0x0002
92
93/*
94 * CCI Return Codes
95 */
96#define CCI_CC_SUCCESS 0x0000
97#define CCI_CC_INVALID_INPUT 0x0002
98#define CCI_CC_PAYLOAD_INVALID_LEN 0x0016
99
100/*
101 * CCI Return Codes
102 */
103#define CCI_SUCCESS 0x0000
104#define CCI_ERROR 0x0001
105#define CCI_INVALID_TYPE 0x0002
106
107typedef struct _wait_msg {
108 sys_snode_t node;
110 int64_t exp_to_ms;
113
114/*CCI command handler */
115uint8_t mctp_cci_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params);
116void cci_read_resp_handler(void *args, uint8_t *rbuf, uint16_t rlen, uint16_t ret_code);
117bool cci_get_chip_temp(void *mctp_p, mctp_ext_params ext_params, int16_t *chip_temp);
118bool cci_get_chip_fw_version(void *mctp_p, mctp_ext_params ext_params, uint8_t *fw_version,
119 uint8_t *return_len);
122
123/* send CCI command message through mctp */
124uint8_t mctp_cci_send_msg(void *mctp_p, mctp_cci_msg *msg);
125
126uint16_t mctp_cci_read(void *mctp_p, mctp_cci_msg *msg, uint8_t *rbuf, uint16_t rbuf_len);
127
128typedef struct __attribute__((__packed__)) {
129 uint8_t health_status;
130 uint8_t media_status;
131 uint8_t additional_status;
132 uint8_t life_used;
133 int16_t dev_temp;
134 uint32_t shutdown_cnt;
135 uint32_t volatile_mem_err_cnt;
136 uint32_t persistent_mem_err_cnt;
138
139typedef struct _cci_fw_info_resp {
141 union {
142 uint8_t value;
143 struct {
144 uint8_t ACTIVE_FW_SLOT : 3;
146 uint8_t RESV : 2;
156
157typedef struct _cci_transfer_fw_req {
158 uint8_t action;
159 uint8_t slot;
160 uint16_t reserved_1;
161 uint32_t offset;
165
166typedef struct _cci_activate_fw_req {
167 uint8_t action;
168 uint8_t slot;
170
176};
177
184};
185
189};
190
191#endif /* _CCI_H */
struct _cci_recv_resp_arg cci_recv_resp_arg
mctp_cci_hdr
Definition: cci.h:69
int pal_get_cci_timeout_ms()
Definition: plat_mctp.c:406
bool cci_get_chip_fw_version(void *mctp_p, mctp_ext_params ext_params, uint8_t *fw_version, uint8_t *return_len)
uint8_t mctp_cci_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params)
ACTIVATE_FW_OPTION
Definition: cci.h:186
@ NEXT_COLD_RESET_ACTIVE_FW
Definition: cci.h:188
@ ONLINE_ACTIVE_FW
Definition: cci.h:187
ACTIVE_FW_SLOT
Definition: cci.h:171
@ SLOT3_FW_ACTIVE
Definition: cci.h:174
@ SLOT1_FW_ACTIVE
Definition: cci.h:172
@ SLOT2_FW_ACTIVE
Definition: cci.h:173
@ SLOT4_FW_ACTIVE
Definition: cci.h:175
struct _cci_fw_info_resp cci_fw_info_resp
int pal_get_cci_internal_ms()
bool cci_get_chip_temp(void *mctp_p, mctp_ext_params ext_params, int16_t *chip_temp)
#define TRANSFER_FW_RESV_LEN
Definition: cci.h:42
uint8_t(* mctp_cci_cmd_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *)
Definition: cci.h:82
#define GET_FW_INFO_REVISION_LEN
Definition: cci.h:41
struct _cci_transfer_fw_req cci_transfer_fw_req
struct _cci_activate_fw_req cci_activate_fw_req
CCI_CMD
Definition: cci.h:21
@ CCI_ACTIVATE_FW
Definition: cci.h:25
@ CCI_TRANSFER_FW
Definition: cci.h:24
@ CCI_GET_FW_INFO
Definition: cci.h:23
@ CCI_GET_HEALTH_INFO
Definition: cci.h:22
void cci_read_resp_handler(void *args, uint8_t *rbuf, uint16_t rlen, uint16_t ret_code)
struct _mctp_cci_cmd_handler mctp_cci_cmd_handler_t
uint8_t(* cci_cmd_proc_fn)(void *, uint8_t *, uint16_t, uint8_t *, uint16_t *, void *)
Definition: cci.h:83
struct _wait_msg wait_msg
uint16_t mctp_cci_read(void *mctp_p, mctp_cci_msg *msg, uint8_t *rbuf, uint16_t rbuf_len)
#define GET_FW_INFO_RESV_LEN
Definition: cci.h:40
cci_health_info_resp
Definition: cci.h:137
#define TRANSFER_FW_DATA_LEN
Definition: cci.h:43
TRANSFER_FW_OPTION
Definition: cci.h:178
@ END_TRANSFER
Definition: cci.h:182
@ CONTINUE_FW_TRANSFER
Definition: cci.h:181
@ INITIATE_FW_TRANSFER
Definition: cci.h:180
@ FULL_FW_TRANSFER
Definition: cci.h:179
@ ABORT_TRANSFER
Definition: cci.h:183
uint8_t mctp_cci_send_msg(void *mctp_p, mctp_cci_msg *msg)
uint8_t op
Definition: mctp_ctrl.h:0
uint8_t rsv
Definition: pldm_monitor.h:2
Definition: pldm_smbios.h:61
Definition: cci.h:166
uint8_t action
Definition: cci.h:167
uint8_t slot
Definition: cci.h:168
Definition: cci.h:139
union _cci_fw_info_resp::@44 fw_slot_info
uint8_t ACTIVE_FW_SLOT
Definition: cci.h:144
uint8_t slot3_fw_revision[GET_FW_INFO_REVISION_LEN]
Definition: cci.h:153
uint8_t RESV
Definition: cci.h:146
struct _cci_fw_info_resp::@44::@45 fields
uint8_t reserved[GET_FW_INFO_RESV_LEN]
Definition: cci.h:150
uint8_t NEXT_ACTIVE_FW_SLOT
Definition: cci.h:145
uint8_t fw_slot_supported
Definition: cci.h:140
uint8_t value
Definition: cci.h:142
uint8_t fw_active_capability
Definition: cci.h:149
uint8_t slot4_fw_revision[GET_FW_INFO_REVISION_LEN]
Definition: cci.h:154
uint8_t slot1_fw_revision[GET_FW_INFO_REVISION_LEN]
Definition: cci.h:151
uint8_t slot2_fw_revision[GET_FW_INFO_REVISION_LEN]
Definition: cci.h:152
Definition: cci.h:45
void(* handler_query)(uint8_t *, uint16_t)
Definition: cci.h:47
CCI_CMD type
Definition: cci.h:46
Definition: cci.h:50
uint16_t rbuf_len
Definition: cci.h:53
struct k_msgq * msgq
Definition: cci.h:51
uint8_t * rbuf
Definition: cci.h:52
uint16_t return_len
Definition: cci.h:54
Definition: cci.h:157
uint8_t data[TRANSFER_FW_DATA_LEN]
Definition: cci.h:163
uint8_t reserved_2[TRANSFER_FW_RESV_LEN]
Definition: cci.h:162
uint32_t offset
Definition: cci.h:161
uint8_t action
Definition: cci.h:158
uint16_t reserved_1
Definition: cci.h:160
uint8_t slot
Definition: cci.h:159
Definition: cci.h:85
uint8_t cmd_code
Definition: cci.h:86
mctp_cci_cmd_fn fn
Definition: cci.h:87
Definition: mctp.h:98
Definition: mctp.h:153
Definition: cci.h:107
mctp_cci_msg msg
Definition: cci.h:111
int64_t exp_to_ms
Definition: cci.h:110
mctp * mctp_inst
Definition: cci.h:109
sys_snode_t node
Definition: cci.h:108
Definition: cci.h:71
uint8_t * pl_data
Definition: cci.h:73
mctp_ext_params ext_params
Definition: cci.h:74
mctp_cci_hdr hdr
Definition: cci.h:72
void * timeout_cb_fn_args
Definition: cci.h:79
void * recv_resp_cb_args
Definition: cci.h:76
uint16_t timeout_ms
Definition: cci.h:77