OpenBIC
OpenSource Bridge-IC
ncsi.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 _NCSI_H
18#define _NCSI_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "mctp.h"
25
26#define MONITOR_THREAD_STACK_SIZE 1024
27
28#define NCSI_PAYLOAD_LENGTH_MAX 0xFFF
29#define NCSI_PAYLOAD_LENGTH_LOW_MASK 0xFF
30#define NCSI_PAYLOAD_LENGTH_HIGH_MASK 0xF00
31#define NCSI_CHECHSUM_LENGTH 4
32
33typedef enum {
34 NCSI_OEM = 0x50,
35} NCSI_CMD;
36
43};
44
46 NCSI_NO_ERROR = 0x0000,
58};
59
64};
65
69};
70
75};
76
77typedef struct __attribute__((packed)) {
78 uint8_t msg_type : 7;
79 uint8_t ic : 1;
80 uint8_t mc_id;
81 uint8_t header_revision;
82 uint8_t reserved_1;
83 uint8_t inst_id;
84
85 union {
86 struct {
87 uint8_t command : 7;
88 uint8_t rq : 1;
89 };
90 uint8_t packet_type;
91 };
92
93 uint8_t channel_id;
94 uint8_t payload_length_high : 4;
95 uint8_t reserved_2 : 4;
96 uint8_t payload_length_low;
97 uint64_t reserved_3;
99
100typedef struct _ncsi_msg {
102 uint8_t *buf;
103 uint16_t len;
105 void (*recv_resp_cb_fn)(void *, uint8_t *, uint16_t);
107 uint16_t timeout_ms;
108 void (*timeout_cb_fn)(void *);
111
112typedef struct _ncsi {
113 /* ncsi message response timeout prcoess resource */
115 struct k_thread thread_data;
117
118 /* store the msg that are not yet to receive the response */
121
122 /* store the msg that are not yet to send the response */
125
126 void *interface; /* the ncsi module over which interface, as mctp */
127 uint8_t user_idx; /* the alias index for this ncsi instance from application
128 layer */
130
132 uint32_t checksum;
133} __attribute__((packed));
134
137 uint16_t reason_code;
138 uint32_t checksum;
139} __attribute__((packed));
140
142 uint32_t checksum;
143} __attribute__((packed));
144
147 uint16_t reason_code;
150 uint8_t link_type;
151 uint8_t log_state : 4;
152 uint8_t phys_state : 4;
153 uint8_t reserved1;
155 uint8_t reserved2;
157 uint32_t checksum;
158} __attribute__((packed));
159
160/* send the ncsi command message through mctp */
161uint8_t mctp_ncsi_send_msg(void *mctp_p, ncsi_msg *msg);
162uint8_t mctp_ncsi_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params);
163uint16_t mctp_ncsi_read(void *mctp_p, ncsi_msg *msg, uint8_t *rbuf, uint16_t rbuf_len);
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif /* _NCSI_H */
uint16_t mctp_ncsi_read(void *mctp_p, ncsi_msg *msg, uint8_t *rbuf, uint16_t rbuf_len)
struct _ncsi ncsi_t
ncsi_reason_codes
Definition: ncsi.h:45
@ NCSI_INFORMATION_NOT_AVAILABLE
Definition: ncsi.h:52
@ NCSI_COMMAND_TIMEOUT
Definition: ncsi.h:55
@ NCSI_CHANNEL_NOT_READY
Definition: ncsi.h:49
@ NCSI_INVALID_PAYLOAD_LENGTH
Definition: ncsi.h:51
@ NCSI_SECONDARY_DEVICE_NOT_POWERED
Definition: ncsi.h:56
@ NCSI_PACKAGE_NOT_READY
Definition: ncsi.h:50
@ NCSI_UNSUPPORTED_COMMAND_TYPE
Definition: ncsi.h:57
@ NCSI_NO_ERROR
Definition: ncsi.h:46
@ NCSI_INTERVENTION_REQUIRED
Definition: ncsi.h:53
@ NCSI_PARAMETER_IS_INVALID
Definition: ncsi.h:48
@ NCSI_LINK_COMMANDS_FAILED_HARDWARE_ACCESS_ERROR
Definition: ncsi.h:54
@ NCSI_INTERFACE_INITIALIZAION_REQUIRED
Definition: ncsi.h:47
#define MONITOR_THREAD_STACK_SIZE
Definition: ncsi.h:26
ncsi_command_rq
Definition: ncsi.h:66
@ NCSI_COMMAND_RESPONSE
Definition: ncsi.h:68
@ NCSI_COMMAND_REQUEST
Definition: ncsi.h:67
uint8_t mctp_ncsi_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params)
struct _ncsi_msg ncsi_msg
ncsi_command_codes
Definition: ncsi.h:60
@ NCSI_COMMAND_GET_INFINIBAND_LINK_STATUS
Definition: ncsi.h:62
@ NCSI_COMMAND_CLEAR_INITIAL_STATE
Definition: ncsi.h:61
@ NCSI_COMMAND_OEM
Definition: ncsi.h:63
infiniband_link_status_link_type
Definition: ncsi.h:71
@ NCSI_IB_LINK_TYPE_ETHERNET
Definition: ncsi.h:72
@ NCSI_IB_LINK_TYPE_UNKNOWN
Definition: ncsi.h:74
@ NCSI_IB_LINK_TYPE_INFINIBAND
Definition: ncsi.h:73
ncsi_response_codes
Definition: ncsi.h:37
@ NCSI_COMMAND_FAILED
Definition: ncsi.h:39
@ NCSI_DELAYED_RESPONSE
Definition: ncsi.h:42
@ NCSI_COMMAND_COMPLETED
Definition: ncsi.h:38
@ NCSI_COMMAND_UNSUPPORTED
Definition: ncsi.h:41
@ NCSI_COMMAND_UNAVAILABLE
Definition: ncsi.h:40
struct __attribute__((packed))
Definition: ncsi.h:77
uint8_t mctp_ncsi_send_msg(void *mctp_p, ncsi_msg *msg)
ncsi_hdr
Definition: ncsi.h:98
NCSI_CMD
Definition: ncsi.h:33
@ NCSI_OEM
Definition: ncsi.h:34
Definition: pldm_smbios.h:61
Definition: mctp.h:98
Definition: ncsi.h:100
uint16_t timeout_ms
Definition: ncsi.h:107
void * recv_resp_cb_args
Definition: ncsi.h:106
mctp_ext_params ext_params
Definition: ncsi.h:104
void(* timeout_cb_fn)(void *)
Definition: ncsi.h:108
void(* recv_resp_cb_fn)(void *, uint8_t *, uint16_t)
Definition: ncsi.h:105
uint16_t len
Definition: ncsi.h:103
uint8_t * buf
Definition: ncsi.h:102
ncsi_hdr hdr
Definition: ncsi.h:101
void * timeout_cb_fn_args
Definition: ncsi.h:109
Definition: ncsi.h:112
struct k_mutex wait_send_resp_list_mutex
Definition: ncsi.h:124
void * interface
Definition: ncsi.h:126
sys_slist_t wait_send_resp_list
Definition: ncsi.h:123
struct k_mutex wait_recv_resp_list_mutex
Definition: ncsi.h:120
K_KERNEL_STACK_MEMBER(monitor_thread_stack, MONITOR_THREAD_STACK_SIZE)
uint8_t user_idx
Definition: ncsi.h:127
sys_slist_t wait_recv_resp_list
Definition: ncsi.h:119
struct k_thread thread_data
Definition: ncsi.h:115
k_tid_t monitor_task
Definition: ncsi.h:114
Definition: ncsi.h:131
uint32_t checksum
Definition: ncsi.h:132
Definition: ncsi.h:135
uint32_t checksum
Definition: ncsi.h:138
uint16_t reason_code
Definition: ncsi.h:137
uint16_t response_code
Definition: ncsi.h:136
uint8_t rq
Definition: plat_pldm.h:6
uint8_t inst_id
Definition: plat_pldm.h:3