OpenBIC
OpenSource Bridge-IC
pldm.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 _PLDM_H
18#define _PLDM_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "mctp.h"
25#include "pldm_base.h"
26#include "pldm_oem.h"
27#include "pldm_monitor.h"
29#include "pldm_state_set.h"
30#include "pldm_smbios.h"
31#include "ipmb.h"
32
33#define MONITOR_THREAD_STACK_SIZE 1024
34
35#define PLDM_MAX_DATA_SIZE_DEFAULT 512
36
37#ifndef PLDM_MAX_DATA_SIZE
38#define PLDM_MAX_DATA_SIZE PLDM_MAX_DATA_SIZE_DEFAULT
39#endif
40typedef uint8_t (*pldm_cmd_proc_fn)(void *, uint8_t *, uint16_t, uint8_t, uint8_t *, uint16_t *,
41 void *);
42
43typedef enum {
49 PLDM_TYPE_OEM = 0x3F
51
55};
56
57typedef struct _pldm_cmd_handler {
58 uint8_t cmd_code;
61
62typedef struct __attribute__((packed)) {
63 uint8_t msg_type : 7;
64 uint8_t ic : 1;
65
66 union {
67 struct {
68 uint8_t inst_id : 5;
69 uint8_t rsvd : 1;
70 uint8_t d : 1;
71 uint8_t rq : 1;
72 };
73 uint8_t req_d_id;
74 };
75
76 uint8_t pldm_type : 6;
77 uint8_t ver : 2;
78 uint8_t cmd;
80
81typedef struct __attribute__((packed)) {
82 pldm_hdr common_hdr;
83 uint8_t resp_comp_code;
85
86typedef struct _pldm_msg {
88 uint8_t *buf;
89 uint16_t len;
91 void (*recv_resp_cb_fn)(void *, uint8_t *, uint16_t);
93 uint16_t timeout_ms;
94 void (*timeout_cb_fn)(void *);
97
98typedef struct _pldm {
99 /* pldm message response timeout prcoess resource */
101 struct k_thread thread_data;
103
104 /* store the msg that are not yet to receive the response */
107
108 /* store the msg that are not yet to send the response */
111
112 void *interface; /* the pldm module over which interface, as mctp */
113 uint8_t user_idx; /* the alias index for this pldm instance from application
114 layer */
116
118 uint8_t *ptr;
119 size_t length;
120};
121
124 uint8_t netfn_lun;
125 uint8_t cmd;
127 uint8_t first_data;
128} __attribute__((packed));
129
130/* the pldm command handler */
131uint8_t mctp_pldm_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params);
132
133/* send the pldm command message through mctp */
134uint8_t mctp_pldm_send_msg(void *mctp_p, pldm_msg *msg);
135int pldm_send_ipmi_response(uint8_t interface, ipmi_msg *msg);
137
138uint16_t mctp_pldm_read(void *mctp_p, pldm_msg *msg, uint8_t *rbuf, uint16_t rbuf_len);
139
140pldm_t *pldm_init(void *interface, uint8_t user_idx);
141
142uint8_t get_supported_pldm_type(uint8_t *buf, uint8_t buf_size);
143
144uint8_t get_supported_pldm_commands(PLDM_TYPE type, uint8_t *buf, uint8_t buf_size);
145
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* _PLDM_H */
pldm_resp_hdr
Definition: pldm.h:84
pldm_t * pldm_init(void *interface, uint8_t user_idx)
PLDM_TYPE
Definition: pldm.h:43
@ PLDM_TYPE_BASE
Definition: pldm.h:44
@ PLDM_TYPE_OEM
Definition: pldm.h:49
@ PLDM_TYPE_SMBIOS
Definition: pldm.h:45
@ PLDM_TYPE_PLAT_MON_CTRL
Definition: pldm.h:46
@ PLDM_TYPE_BIOS_CTRL_CONF
Definition: pldm.h:47
@ PLDM_TYPE_FW_UPDATE
Definition: pldm.h:48
uint8_t get_supported_pldm_commands(PLDM_TYPE type, uint8_t *buf, uint8_t buf_size)
Definition: pldm.c:519
uint8_t(* pldm_cmd_proc_fn)(void *, uint8_t *, uint16_t, uint8_t, uint8_t *, uint16_t *, void *)
Definition: pldm.h:40
int pldm_send_ipmi_request(ipmi_msg *msg)
Definition: pldm.c:607
#define MONITOR_THREAD_STACK_SIZE
Definition: pldm.h:33
pldm_hdr
Definition: pldm.h:79
uint8_t cmd
Definition: pldm.h:2
int pldm_send_ipmi_response(uint8_t interface, ipmi_msg *msg)
Definition: pldm.c:554
PLDM_MESSAGE_TYPE
Definition: pldm.h:52
@ PLDM_REQUEST
Definition: pldm.h:54
@ PLDM_RESPONSE
Definition: pldm.h:53
uint16_t mctp_pldm_read(void *mctp_p, pldm_msg *msg, uint8_t *rbuf, uint16_t rbuf_len)
Definition: pldm.c:161
uint8_t mctp_pldm_send_msg(void *mctp_p, pldm_msg *msg)
Definition: pldm.c:409
struct _pldm pldm_t
struct __attribute__((packed))
Definition: pldm.h:62
uint8_t mctp_pldm_cmd_handler(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params)
Definition: pldm.c:332
uint8_t get_supported_pldm_type(uint8_t *buf, uint8_t buf_size)
Get the supported PLDM types.
Definition: pldm.c:495
struct _pldm_cmd_handler pldm_cmd_handler
struct _pldm_msg pldm_msg
uint8_t type
Definition: pldm_base.h:0
Definition: pldm_smbios.h:61
Definition: mctp.h:98
Definition: pldm.h:57
uint8_t cmd_code
Definition: pldm.h:58
pldm_cmd_proc_fn fn
Definition: pldm.h:59
Definition: pldm.h:122
uint8_t completion_code
Definition: pldm.h:123
uint8_t netfn_lun
Definition: pldm.h:124
uint8_t ipmi_comp_code
Definition: pldm.h:126
uint8_t first_data
Definition: pldm.h:127
uint8_t cmd
Definition: pldm.h:125
Definition: pldm.h:86
void * recv_resp_cb_args
Definition: pldm.h:92
void(* recv_resp_cb_fn)(void *, uint8_t *, uint16_t)
Definition: pldm.h:91
uint8_t * buf
Definition: pldm.h:88
uint16_t timeout_ms
Definition: pldm.h:93
pldm_hdr hdr
Definition: pldm.h:87
uint16_t len
Definition: pldm.h:89
mctp_ext_params ext_params
Definition: pldm.h:90
void * timeout_cb_fn_args
Definition: pldm.h:95
void(* timeout_cb_fn)(void *)
Definition: pldm.h:94
Definition: pldm.h:98
void * interface
Definition: pldm.h:112
struct k_mutex wait_recv_resp_list_mutex
Definition: pldm.h:106
k_tid_t monitor_task
Definition: pldm.h:100
sys_slist_t wait_send_resp_list
Definition: pldm.h:109
struct k_mutex wait_send_resp_list_mutex
Definition: pldm.h:110
struct k_thread thread_data
Definition: pldm.h:101
uint8_t user_idx
Definition: pldm.h:113
sys_slist_t wait_recv_resp_list
Definition: pldm.h:105
K_KERNEL_STACK_MEMBER(monitor_thread_stack, MONITOR_THREAD_STACK_SIZE)
Definition: ipmb.h:165
Definition: pldm.h:117
uint8_t * ptr
Definition: pldm.h:118
size_t length
Definition: pldm.h:119
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 pldm_type
Definition: plat_pldm.h:11
uint8_t inst_id
Definition: plat_pldm.h:3
uint8_t req_d_id
Definition: plat_pldm.h:8
uint8_t ver
Definition: plat_pldm.h:12