OpenBIC
OpenSource Bridge-IC
ipmi.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 IPMI_H
18#define IPMI_H
19
20#include <string.h>
21#include "ipmb.h"
22#include "plat_version.h"
23
24#define IPMI_THREAD_STACK_SIZE 4096
25#define IPMI_BUF_LEN 10
26#define IPMI_HANDLE_THREAD_STACK_SIZE 4096
27#ifndef IANA_ID
28#define IANA_ID 0x00A015 // Meta's IANA
29#endif
30
31#define SENSOR_EVENT_MESSAGES_ENABLE (1 << 7)
32#define SENSOR_SCANNING_ENABLE (1 << 6)
33#define SENSOR_READING_STATE_UNAVAILABLE (1 << 5)
34
35extern uint8_t IPMB_inf_index_map[];
36extern uint8_t isPwOn;
37extern struct k_msgq ipmi_msgq;
38extern struct k_msgq self_ipmi_msgq;
39
41 uint8_t netfn;
42 uint8_t cmd;
43 uint8_t data[0];
44};
45
47 uint8_t netfn;
48 uint8_t cmd;
49 uint8_t cmplt_code;
50 uint8_t data[0];
51};
52
53typedef struct common_addsel_msg_t {
54 uint8_t InF_target;
55 uint8_t sensor_type;
57 uint8_t event_type;
58 uint8_t event_data1;
59 uint8_t event_data2;
60 uint8_t event_data3;
62
63static inline void pack_ipmi_resp(struct ipmi_response *resp, ipmi_msg *ipmi_resp)
64{
65 resp->netfn = (ipmi_resp->netfn + 1) << 2; // ipmi netfn response package
66 resp->cmd = ipmi_resp->cmd;
67 resp->cmplt_code = ipmi_resp->completion_code;
68 if (ipmi_resp->data_len != 0) {
69 memcpy(resp->data, ipmi_resp->data, ipmi_resp->data_len);
70 }
71}
72
73// If command is from KCS, we need to check dimm presnece status
74bool pal_set_dimm_presence_status(uint8_t *buf);
75// If command is from KCS, we need to check whether BIC support this command.
76bool pal_request_msg_to_BIC_from_HOST(uint8_t netfn, uint8_t cmd);
77// If command is from KCS, we need to check whether BIC responds immediately.
78bool pal_immediate_respond_from_HOST(uint8_t netfn, uint8_t cmd);
79// If command is from KCS, we need to check whether system information is set via BIC.
80int pal_record_bios_fw_version(uint8_t *buf, uint8_t size);
81// If command is from ME, we need to check whether BIC support this command.
82bool pal_request_msg_to_BIC_from_ME(uint8_t netfn, uint8_t cmd);
83// For the command that BIC only bridges it, BIC doesn't return the command directly
84// For this kind of commands we return through IPMB that receiving the responses from the other devices.
85bool pal_is_not_return_cmd(uint8_t netfn, uint8_t cmd);
87void ipmi_init(void);
88void IPMI_handler(void *arug0, void *arug1, void *arug2);
89
90enum {
91 /* generic completion codes 00h, C0h-FFh */
92 CC_SUCCESS = 0x00,
96 CC_TIMEOUT = 0xC3,
108
109 /* device-specific (OEM) codes 01h-7Eh */
110
111 /* command-specific codes 80h-BEh */
117};
118
119// Network Function Codes (IPMI/Section 5.1)
120enum {
151};
152
153// Application Command Codes (0x06)
154enum {
169};
170
171// Chassis Command Codes (0x00)
172enum {
174};
175
176// Sensor Command Codes (0x04)
177enum {
180};
181
182// Storage Command Codes (0x0A)
183enum {
193};
194
195// Application Extension Code (0x2c)
196enum {
200};
201
202// OEM NM Command Codes (0x2E)
203enum {
205};
206
207// OEM Command Codes (0x30)
208enum {
221};
222
223// OEM Q Command Codes (0x36)
224enum {
227};
228
229// OEM 1S Command Codes (0x38)
230enum {
261
279 // Debug command
281
286
289
297
313};
314
315enum {
318};
319
321
322#endif
uint8_t netfn
Definition: ipmb.h:1
ipmb_error
Definition: ipmb.h:152
bool pal_immediate_respond_from_HOST(uint8_t netfn, uint8_t cmd)
Definition: ipmi.c:184
struct k_msgq ipmi_msgq
struct common_addsel_msg_t common_addsel_msg_t
@ CMD_OEM_Q_GET_DIMM_INFO
Definition: ipmi.h:226
@ CMD_OEM_Q_SET_DIMM_INFO
Definition: ipmi.h:225
bool common_add_sel_evt_record(common_addsel_msg_t *sel_msg)
Definition: ipmi.c:221
struct k_msgq self_ipmi_msgq
uint8_t IPMB_inf_index_map[]
void ipmi_init(void)
Definition: ipmi.c:454
@ CMD_DCMI_GET_BOOT_PROGRESS_CODE
Definition: ipmi.h:199
@ CMD_DCMI_SEND_BOOT_PROGRESS_CODE
Definition: ipmi.h:198
@ CMD_DCMI_GET_PICMG_PROPERTIES
Definition: ipmi.h:197
@ CC_SENSOR_NOT_PRESENT
Definition: ipmi.h:103
@ CC_SUCCESS
Definition: ipmi.h:92
@ CC_BRIDGE_MSG_ERR
Definition: ipmi.h:114
@ CC_LENGTH_EXCEEDED
Definition: ipmi.h:101
@ CC_INVALID_LENGTH
Definition: ipmi.h:100
@ CC_INVALID_LUN
Definition: ipmi.h:95
@ CC_INVALID_IANA
Definition: ipmi.h:116
@ CC_INVALID_DATA_FIELD
Definition: ipmi.h:104
@ CC_NODE_BUSY
Definition: ipmi.h:93
@ CC_OUT_OF_SPACE
Definition: ipmi.h:97
@ CC_INVALID_PARAM
Definition: ipmi.h:112
@ CC_NOT_SUPP_IN_CURR_STATE
Definition: ipmi.h:106
@ CC_FRU_DEV_BUSY
Definition: ipmi.h:113
@ CC_UNSPECIFIED_ERROR
Definition: ipmi.h:107
@ CC_INVALID_CMD
Definition: ipmi.h:94
@ CC_I2C_BUS_ERROR
Definition: ipmi.h:115
@ CC_DATA_TRUNCATED
Definition: ipmi.h:99
@ CC_PARAM_OUT_OF_RANGE
Definition: ipmi.h:102
@ CC_TIMEOUT
Definition: ipmi.h:96
@ CC_CAN_NOT_RESPOND
Definition: ipmi.h:105
@ CC_INVALID_RESERVATION
Definition: ipmi.h:98
ipmb_error notify_ipmi_client(ipmi_msg_cfg *msg_cfg)
int pal_record_bios_fw_version(uint8_t *buf, uint8_t size)
Definition: ipmi.c:194
@ CMD_OEM_POST_START
Definition: ipmi.h:212
@ CMD_OEM_GET_BOARD_ID
Definition: ipmi.h:209
@ CMD_OEM_GET_SET_FAN_CTRL_MODE
Definition: ipmi.h:219
@ CMD_OEM_GET_CHASSIS_POSITION
Definition: ipmi.h:220
@ CMD_OEM_NM_SENSOR_READ
Definition: ipmi.h:215
@ CMD_OEM_CABLE_DETECTION
Definition: ipmi.h:214
@ CMD_OEM_GET_MB_INDEX
Definition: ipmi.h:217
@ CMD_OEM_SET_FAN_DUTY_MANUAL
Definition: ipmi.h:218
@ CMD_OEM_GET_HTTP_BOOT_ATTR
Definition: ipmi.h:211
@ CMD_OEM_POST_END
Definition: ipmi.h:213
@ CMD_OEM_SET_SYSTEM_GUID
Definition: ipmi.h:216
@ CMD_OEM_GET_HTTP_BOOT_DATA
Definition: ipmi.h:210
void IPMI_handler(void *arug0, void *arug1, void *arug2)
Definition: ipmi.c:429
uint8_t isPwOn
bool pal_set_dimm_presence_status(uint8_t *buf)
Definition: ipmi.c:166
@ CMD_OEM_1S_SEND_4BYTE_POST_CODE_TO_BMC
Definition: ipmi.h:265
@ CMD_OEM_1S_CLEAR_CMOS
Definition: ipmi.h:253
@ CMD_OEM_1S_GET_VR_MONITOR_STATUS
Definition: ipmi.h:246
@ CMD_OEM_1S_SAFE_WRITE_READ_M2_DATA
Definition: ipmi.h:267
@ CMD_OEM_1S_PEX_FLASH_READ
Definition: ipmi.h:290
@ CMD_OEM_1S_NOTIFY_PMIC_ERROR
Definition: ipmi.h:302
@ CMD_OEM_1S_SET_GPIO_CONFIG
Definition: ipmi.h:236
@ CMD_OEM_1S_SET_SSD_LED
Definition: ipmi.h:268
@ CMD_OEM_1S_COPY_FLASH_IMAGE
Definition: ipmi.h:277
@ CMD_OEM_1S_GET_BIC_STATUS
Definition: ipmi.h:263
@ CMD_OEM_1S_SEND_APML_ALERT_TO_BMC
Definition: ipmi.h:305
@ CMD_OEM_1S_SET_ADD_DEBUG_SEL_MODE
Definition: ipmi.h:308
@ CMD_OEM_1S_GET_PCIE_CARD_SENSOR_READING
Definition: ipmi.h:294
@ CMD_OEM_1S_GET_CARD_TYPE
Definition: ipmi.h:300
@ CMD_OEM_1S_JTAG_DATA_SHIFT
Definition: ipmi.h:251
@ CMD_OEM_1S_CONTROL_SENSOR_POLLING
Definition: ipmi.h:273
@ CMD_OEM_1S_12V_CYCLE_SLOT
Definition: ipmi.h:282
@ CMD_OEM_1S_MSG_IN
Definition: ipmi.h:231
@ CMD_OEM_1S_SET_JTAG_TAP_STA
Definition: ipmi.h:250
@ CMD_OEM_1S_GET_SDR
Definition: ipmi.h:304
@ CMD_OEM_1S_SEND_INTERRUPT_TO_BMC
Definition: ipmi.h:237
@ CMD_OEM_1S_GET_HSC_STATUS
Definition: ipmi.h:288
@ CMD_OEM_1S_GET_DIMM_I3C_MUX_SELECTION
Definition: ipmi.h:306
@ CMD_OEM_1S_GET_SSD_STATUS
Definition: ipmi.h:269
@ CMD_OEM_1S_WRITE_READ_DIMM
Definition: ipmi.h:303
@ CMD_OEM_1S_PRE_POWER_OFF_CONTROL
Definition: ipmi.h:307
@ CMD_OEM_1S_APML_READ
Definition: ipmi.h:257
@ CMD_OEM_1S_SEND_APML_REQUEST
Definition: ipmi.h:259
@ CMD_OEM_1S_DEBUG_GET_HW_SIGNAL
Definition: ipmi.h:309
@ CMD_OEM_1S_SET_GPIO
Definition: ipmi.h:234
@ CMD_OEM_1S_PECI_ACCESS
Definition: ipmi.h:255
@ CMD_OEM_1S_GET_SET_BIC_VGPIO
Definition: ipmi.h:271
@ CMD_OEM_1S_GET_BOARD_ID
Definition: ipmi.h:299
@ CMD_OEM_1S_GET_POST_CODE
Definition: ipmi.h:244
@ CMD_OEM_1S_SPI_REGISTER_READ
Definition: ipmi.h:312
@ CMD_OEM_1S_SET_WDT_FEED
Definition: ipmi.h:249
@ CMD_OEM_1S_GET_BIOS_VERSION
Definition: ipmi.h:301
@ CMD_OEM_1S_APML_WRITE
Definition: ipmi.h:258
@ CMD_OEM_1S_MSG_OUT
Definition: ipmi.h:232
@ CMD_OEM_1S_MULTI_ACCURACY_SENSOR_READING
Definition: ipmi.h:298
@ CMD_OEM_1S_GET_APML_RESPONSE
Definition: ipmi.h:260
@ CMD_OEM_1S_RESET_BIC
Definition: ipmi.h:264
@ CMD_OEM_1S_SET_VR_MONITOR_STATUS
Definition: ipmi.h:245
@ CMD_OEM_1S_I2C_DEV_SCAN
Definition: ipmi.h:280
@ CMD_OEM_1S_GET_FAN_DUTY
Definition: ipmi.h:275
@ CMD_OEM_1S_INFORM_PEER_SLED_CYCLE
Definition: ipmi.h:283
@ CMD_OEM_1S_FW_UPDATE
Definition: ipmi.h:239
@ CMD_OEM_1S_GET_BIC_FW_INFO
Definition: ipmi.h:240
@ CMD_OEM_1S_GET_SET_GPIO
Definition: ipmi.h:270
@ CMD_OEM_1S_SENSOR_POLL_EN
Definition: ipmi.h:262
@ CMD_OEM_1S_WRITE_BIC_REGISTER
Definition: ipmi.h:285
@ CMD_OEM_1S_ACCURACY_SENSOR_READING
Definition: ipmi.h:252
@ CMD_OEM_1S_GET_PCIE_RETIMER_TYPE
Definition: ipmi.h:296
@ CMD_OEM_1S_GET_GPIO
Definition: ipmi.h:233
@ CMD_OEM_1S_INFORM_BMC_TO_CONTROL_POWER
Definition: ipmi.h:243
@ CMD_OEM_1S_GET_SET_M2
Definition: ipmi.h:266
@ CMD_OEM_1S_SEND_HOST_POWER_STATE_TO_BMC
Definition: ipmi.h:242
@ CMD_OEM_1S_BMC_IPMB_ACCESS
Definition: ipmi.h:287
@ CMD_OEM_1S_READ_BIC_REGISTER
Definition: ipmi.h:284
@ CMD_OEM_1S_SET_DEVICE_ACTIVE
Definition: ipmi.h:295
@ CMD_OEM_1S_GET_4BYTE_POST_CODE
Definition: ipmi.h:256
@ CMD_OEM_1S_SET_FAN_DUTY_AUTO
Definition: ipmi.h:274
@ CMD_OEM_1S_SEND_POST_CODE_TO_BMC
Definition: ipmi.h:238
@ CMD_OEM_1S_GET_FAN_RPM
Definition: ipmi.h:276
@ CMD_OEM_1S_GET_FW_VERSION
Definition: ipmi.h:241
@ CMD_OEM_1S_BRIDGE_I2C_MSG_BY_COMPNT
Definition: ipmi.h:292
@ CMD_OEM_1S_GET_FW_SHA256
Definition: ipmi.h:272
@ CMD_OEM_1S_GET_GPIO_CONFIG
Definition: ipmi.h:235
@ CMD_OEM_1S_SEND_MCTP_PLDM_COMMAND
Definition: ipmi.h:310
@ CMD_OEM_1S_GET_FPGA_USER_CODE
Definition: ipmi.h:291
@ CMD_GET_COPY_FLASH_STATUS
Definition: ipmi.h:278
@ CMD_OEM_1S_RESET_BMC
Definition: ipmi.h:247
@ CMD_OEM_1S_GET_PCIE_CARD_STATUS
Definition: ipmi.h:293
@ CMD_OEM_1S_ASD_INIT
Definition: ipmi.h:254
@ CMD_OEM_1S_CLEAR_CMET
Definition: ipmi.h:311
@ CMD_OEM_1S_READ_FW_IMAGE
Definition: ipmi.h:248
bool pal_is_not_return_cmd(uint8_t netfn, uint8_t cmd)
Definition: ipmi.c:208
@ CMD_APP_GET_WATCHDOG_TIMER
Definition: ipmi.h:162
@ CMD_APP_GET_SELFTEST_RESULTS
Definition: ipmi.h:158
@ CMD_APP_SET_ACPI_POWER
Definition: ipmi.h:159
@ CMD_APP_GET_SYSTEM_GUID
Definition: ipmi.h:165
@ CMD_APP_GET_DEVICE_GUID
Definition: ipmi.h:160
@ CMD_APP_MASTER_WRITE_READ
Definition: ipmi.h:167
@ CMD_APP_SET_SYS_INFO_PARAMS
Definition: ipmi.h:168
@ CMD_APP_SET_WATCHDOG_TIMER
Definition: ipmi.h:161
@ CMD_APP_GET_CAHNNEL_INFO
Definition: ipmi.h:166
@ CMD_APP_COLD_RESET
Definition: ipmi.h:156
@ CMD_APP_CLEAR_MESSAGE_FLAGS
Definition: ipmi.h:164
@ CMD_APP_WARM_RESET
Definition: ipmi.h:157
@ CMD_APP_GET_BMC_GLOBAL_ENABLES
Definition: ipmi.h:163
@ CMD_APP_GET_DEVICE_ID
Definition: ipmi.h:155
@ CMD_OEM_NM_FORCE_ME_RECOVERY
Definition: ipmi.h:204
@ NETFN_FIRMWARE_RES
Definition: ipmi.h:130
@ NETFN_OEM_1S_RES
Definition: ipmi.h:146
@ NETFN_TRANSPORT_RES
Definition: ipmi.h:134
@ NETFN_APP_RES
Definition: ipmi.h:128
@ NETFN_OEM_STORAGE_REQ
Definition: ipmi.h:141
@ NETFN_STORAGE_REQ
Definition: ipmi.h:131
@ NETFN_DCMI_REQ
Definition: ipmi.h:135
@ NETFN_OEM_Q_REQ
Definition: ipmi.h:143
@ NETFN_OEM_Q_RES
Definition: ipmi.h:144
@ NETFN_OEM_1S_REQ
Definition: ipmi.h:145
@ NETFN_STORAGE_RES
Definition: ipmi.h:132
@ NETFN_OEM_ZION_REQ
Definition: ipmi.h:147
@ NETFN_BRIDGE_RES
Definition: ipmi.h:124
@ NETFN_CHASSIS_REQ
Definition: ipmi.h:121
@ NETFN_NM_REQ
Definition: ipmi.h:137
@ NETFN_DCMI_RES
Definition: ipmi.h:136
@ NETFN_OEM_REQ
Definition: ipmi.h:139
@ NETFN_OEM_ZION_RES
Definition: ipmi.h:148
@ NETFN_NM_RES
Definition: ipmi.h:138
@ NETFN_SENSOR_RES
Definition: ipmi.h:126
@ NETFN_OEM_USB_DBG_REQ
Definition: ipmi.h:149
@ NETFN_SENSOR_REQ
Definition: ipmi.h:125
@ NETFN_FIRMWARE_REQ
Definition: ipmi.h:129
@ NETFN_BRIDGE_REQ
Definition: ipmi.h:123
@ NETFN_APP_REQ
Definition: ipmi.h:127
@ NETFN_OEM_STORAGE_RES
Definition: ipmi.h:142
@ NETFN_OEM_USB_DBG_RES
Definition: ipmi.h:150
@ NETFN_CHASSIS_RES
Definition: ipmi.h:122
@ NETFN_TRANSPORT_REQ
Definition: ipmi.h:133
@ NETFN_OEM_RES
Definition: ipmi.h:140
@ CMD_CHASSIS_GET_CHASSIS_STATUS
Definition: ipmi.h:173
bool pal_request_msg_to_BIC_from_HOST(uint8_t netfn, uint8_t cmd)
Definition: ipmi.c:171
@ INDEX_SLOT3
Definition: ipmi.h:317
@ INDEX_SLOT1
Definition: ipmi.h:316
@ CMD_SENSOR_PLATFORM_EVENT
Definition: ipmi.h:178
@ CMD_SENSOR_GET_SENSOR_READING
Definition: ipmi.h:179
@ CMD_STORAGE_READ_FRUID_DATA
Definition: ipmi.h:185
@ CMD_STORAGE_GET_SEL
Definition: ipmi.h:191
@ CMD_STORAGE_WRITE_FRUID_DATA
Definition: ipmi.h:186
@ CMD_STORAGE_RSV_SDR
Definition: ipmi.h:187
@ CMD_STORAGE_ADD_SEL
Definition: ipmi.h:192
@ CMD_STORAGE_GET_SEL_INFO
Definition: ipmi.h:189
@ CMD_STORAGE_GET_FRUID_INFO
Definition: ipmi.h:184
@ CMD_STORAGE_GET_SDR
Definition: ipmi.h:188
@ CMD_STORAGE_RSV_SEL
Definition: ipmi.h:190
bool pal_request_msg_to_BIC_from_ME(uint8_t netfn, uint8_t cmd)
Definition: ipmi.c:199
uint8_t cmd
Definition: isl69259.c:1
uint16_t size
Definition: pldm_oem.h:0
Definition: ipmi.h:53
uint8_t event_type
Definition: ipmi.h:57
uint8_t sensor_number
Definition: ipmi.h:56
uint8_t event_data1
Definition: ipmi.h:58
uint8_t event_data3
Definition: ipmi.h:60
uint8_t InF_target
Definition: ipmi.h:54
uint8_t event_data2
Definition: ipmi.h:59
uint8_t sensor_type
Definition: ipmi.h:55
Definition: ipmb.h:189
Definition: ipmb.h:165
uint8_t data[IPMI_MSG_MAX_LENGTH]
Definition: ipmb.h:181
uint8_t netfn
Definition: ipmb.h:167
uint16_t data_len
Definition: ipmb.h:180
uint8_t completion_code
Definition: ipmb.h:179
uint8_t cmd
Definition: ipmb.h:178
Definition: ipmi.h:40
uint8_t cmd
Definition: ipmi.h:42
uint8_t data[0]
Definition: ipmi.h:43
uint8_t netfn
Definition: ipmi.h:41
Definition: ipmi.h:46
uint8_t cmd
Definition: ipmi.h:48
uint8_t cmplt_code
Definition: ipmi.h:49
uint8_t data[0]
Definition: ipmi.h:50
uint8_t netfn
Definition: ipmi.h:47