blob: 788ae85d76d784077caff5e2b8676a645ddf6740 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Angel Pons8a3453f2020-04-02 23:48:19 +02002
Johnny Linf4abe512019-10-21 09:54:36 +08003#ifndef __IPMI_OPS_H
4#define __IPMI_OPS_H
Johnny Linf4abe512019-10-21 09:54:36 +08005
6#include <types.h>
Sergii Dmytrukef7dd5d2021-10-22 01:02:32 +03007#include "ipmi_if.h"
Johnny Linf4abe512019-10-21 09:54:36 +08008#define IPMI_BMC_RESET_WDG_TIMER 0x22
9#define IPMI_BMC_SET_WDG_TIMER 0x24
10#define IPMI_BMC_GET_WDG_TIMER 0x25
Johnny Lin53509cf2019-11-14 14:55:04 +080011#define IPMI_BMC_GET_SYSTEM_GUID 0x37
Johnny Linf4abe512019-10-21 09:54:36 +080012
13/* BMC watchdog timeout action */
14enum ipmi_bmc_timeout_action_type {
15 TIMEOUT_NO_ACTION = 0x00,
16 TIMEOUT_HARD_RESET = 0x01,
17 TIMEOUT_POWER_DOWN = 0x02,
18 TIMEOUT_POWER_CYCLE = 0x03,
19};
20/* BMC Watchdog timer */
21struct ipmi_wdt_req {
22 uint8_t timer_use;
23 uint8_t timer_actions;
24 uint8_t pretimeout_interval;
25 uint8_t timer_use_expiration_flags_clr;
26 uint16_t initial_countdown_val;
27} __packed;
28
29struct ipmi_wdt_rsp {
30 struct ipmi_rsp resp;
31 struct ipmi_wdt_req data;
32 uint16_t present_countdown_val;
33} __packed;
34
Johnny Lin53509cf2019-11-14 14:55:04 +080035struct ipmi_get_system_guid_rsp {
36 struct ipmi_rsp resp;
37 uint8_t data[16];
38} __packed;
Johnny Linb9e84482019-12-02 19:44:04 +080039
40struct ipmi_read_fru_data_req {
41 uint8_t fru_device_id;
42 uint16_t fru_offset;
43 uint8_t count; /* count to read, 1-based. */
44} __packed;
45
46struct ipmi_read_fru_data_rsp {
47 struct ipmi_rsp resp;
48 uint8_t count; /* count returned, 1-based. */
49 uint8_t data[CONFIG_IPMI_FRU_SINGLE_RW_SZ];
50} __packed;
51
Morgan Jangea9787a2020-04-09 13:50:43 +080052struct standard_spec_sel_rec {
53 uint32_t timestamp;
54 uint16_t gen_id;
55 uint8_t evm_rev;
56 uint8_t sensor_type;
57 uint8_t sensor_num;
58 uint8_t event_dir_type;
59 uint8_t event_data[3];
Jonathan Zhangcb3eaf62022-10-24 13:48:38 -070060} __packed;
Morgan Jangea9787a2020-04-09 13:50:43 +080061
62struct oem_ts_spec_sel_rec {
63 uint32_t timestamp;
64 uint8_t manf_id[3];
65 uint8_t oem_defined[6];
Jonathan Zhangcb3eaf62022-10-24 13:48:38 -070066} __packed;
Morgan Jangea9787a2020-04-09 13:50:43 +080067
68struct oem_nots_spec_sel_rec {
69 uint8_t oem_defined[13];
Jonathan Zhangcb3eaf62022-10-24 13:48:38 -070070} __packed;
Morgan Jangea9787a2020-04-09 13:50:43 +080071
72/* SEL Event Record */
73struct sel_event_record {
74 uint16_t record_id;
75 uint8_t record_type;
76 union{
77 struct standard_spec_sel_rec standard_type;
78 struct oem_ts_spec_sel_rec oem_ts_type;
79 struct oem_nots_spec_sel_rec oem_nots_type;
80 } sel_type;
81} __packed;
82
83struct ipmi_add_sel_rsp {
84 struct ipmi_rsp resp;
85 uint16_t record_id;
86} __packed;
87
Johnny Linb9e84482019-12-02 19:44:04 +080088/* Platform Management FRU Information Storage Definition Spec. */
89#define PRODUCT_MAN_TYPE_LEN_OFFSET 3
90#define BOARD_MAN_TYPE_LEN_OFFSET 6
Johnny Lind6a47722020-01-22 16:36:17 +080091#define CHASSIS_TYPE_OFFSET 2
Johnny Linb9e84482019-12-02 19:44:04 +080092
93struct ipmi_fru_common_hdr {
94 uint8_t format_version;
95 uint8_t internal_use_area_offset;
96 uint8_t chassis_area_offset;
97 uint8_t board_area_offset;
98 uint8_t product_area_offset;
99 uint8_t multirecord_area_offset;
100 uint8_t pad;
101 uint8_t checksum;
102} __packed;
103
104/* The fru_xxx_info only declares the strings that may be added to SMBIOS. */
105struct fru_product_info {
106 char *manufacturer;
107 char *product_name;
108 char *product_partnumber;
109 char *product_version;
110 char *serial_number;
111 char *asset_tag;
Johnny Lindb654ea2020-04-20 17:32:47 +0800112 char *fru_file_id;
113 char **product_custom;
Paul Menzel2dcc7222022-01-05 13:29:53 +0100114 size_t custom_count; /* Number of custom fields */
Johnny Linb9e84482019-12-02 19:44:04 +0800115};
116
117struct fru_board_info {
118 char *manufacturer;
119 char *product_name;
120 char *serial_number;
121 char *part_number;
Johnny Lindb654ea2020-04-20 17:32:47 +0800122 char *fru_file_id;
123 char **board_custom;
Paul Menzel2dcc7222022-01-05 13:29:53 +0100124 size_t custom_count;
Johnny Linb9e84482019-12-02 19:44:04 +0800125};
126
Johnny Lind6a47722020-01-22 16:36:17 +0800127struct fru_chassis_info {
128 uint8_t chassis_type;
129 char *chassis_partnumber;
130 char *serial_number;
131 char **chassis_custom;
Paul Menzel2dcc7222022-01-05 13:29:53 +0100132 size_t custom_count;
Johnny Lind6a47722020-01-22 16:36:17 +0800133};
134
Johnny Linb9e84482019-12-02 19:44:04 +0800135struct fru_info_str {
136 struct fru_product_info prod_info;
137 struct fru_board_info board_info;
Johnny Lind6a47722020-01-22 16:36:17 +0800138 struct fru_chassis_info chassis_info;
Johnny Linb9e84482019-12-02 19:44:04 +0800139};
140
141enum typecode {
142 BINARY = 0,
143 BCD_PLUS = 1,
144 ASCII_6BIT = 2,
145 ASCII_8BIT = 3,
146};
147
148enum fru_area {
149 INTERNAL_USE_AREA = 0,
150 CHASSIS_INFO_AREA = 1,
151 BOARD_INFO_AREA = 2,
152 PRODUCT_INFO_AREA = 3,
153 MULTIRECORD_INFO_AREA = 4,
154};
Johnny Linf4abe512019-10-21 09:54:36 +0800155/*
156 * Initialize and start BMC FRB2 watchdog timer with the
157 * provided timer countdown and action values.
158 * Returns CB_SUCCESS on success and CB_ERR if an error occurred
159 */
160enum cb_err ipmi_init_and_start_bmc_wdt(const int port, uint16_t countdown,
161 uint8_t action);
162/* Returns CB_SUCCESS on success and CB_ERR if an error occurred */
163enum cb_err ipmi_stop_bmc_wdt(const int port);
164
Johnny Lin53509cf2019-11-14 14:55:04 +0800165/* IPMI get BMC system GUID and store it to parameter uuid.
166 * Returns CB_SUCCESS on success and CB_ERR if an error occurred */
167enum cb_err ipmi_get_system_guid(const int port, uint8_t *uuid);
Johnny Linb9e84482019-12-02 19:44:04 +0800168
169/* Read all FRU inventory areas string data into fru_info_str with
170 * the same FRU device id. */
171void read_fru_areas(const int port, uint8_t id, uint16_t offset,
172 struct fru_info_str *fru_info_str);
173
174/* Read a particular FRU inventory area into fru_info_str. */
175void read_fru_one_area(const int port, uint8_t id, uint16_t offset,
176 struct fru_info_str *fru_info_str, enum fru_area fru_area);
Morgan Jangea9787a2020-04-09 13:50:43 +0800177
178/* Add a SEL record entry, returns CB_SUCCESS on success and CB_ERR
179 * if an error occurred */
180enum cb_err ipmi_add_sel(const int port, struct sel_event_record *sel);
Johnny Lindb654ea2020-04-20 17:32:47 +0800181
182/* Print all IPMI read FRU data */
183void print_fru_areas(struct fru_info_str *fru_info_str);
Johnny Linf4abe512019-10-21 09:54:36 +0800184#endif