1 /* SPDX-License-Identifier: GPL-2.0-or-later */
6 #include <commonlib/bsd/cb_err.h>
7 #include <device/pci_type.h>
9 #define IPMI_NETFN_OEM 0x30
10 #define IPMI_OEM_SET_PPIN 0x77
11 #define IPMI_BMC_SET_POST_START 0x73
12 #define IPMI_OEM_SET_BIOS_BOOT_ORDER 0x52
13 #define IPMI_OEM_GET_BIOS_BOOT_ORDER 0x53
14 #define IPMI_OEM_GET_BOARD_ID 0x37
16 #define CMOS_BIT (1 << 1)
17 #define VALID_BIT (1 << 7)
18 #define CLEAR_CMOS_AND_VALID_BIT(x) ((x) &= ~(CMOS_BIT | VALID_BIT))
19 #define SET_CMOS_AND_VALID_BIT(x) ((x) |= (CMOS_BIT | VALID_BIT))
20 #define IS_CMOS_AND_VALID_BIT(x) ((x)&CMOS_BIT && (x)&VALID_BIT)
44 struct ipmi_pci_dev_fn
{
50 struct ipmi_sel_pcie_dev_err
{
56 struct ipmi_pci_dev_fn bdf
;
57 uint16_t primary_err_count
;
62 struct iio_port_location
{
68 struct ipmi_sel_iio_err
{
73 struct iio_port_location loc
;
74 uint8_t iio_stack_num
;
88 PCIE_CRPT_DATA_CONTMT
= 4,
92 struct ipmi_sel_pcie_dev_fail
{
99 uint16_t failure_details1
; /* if DPC, DPC sts reg of root port */
100 uint16_t failure_details2
; /* if DPC, source ID of root port */
105 struct ipmi_config_rsp
{
106 uint8_t board_sku_id
;
107 uint8_t board_rev_id
;
109 uint8_t slot_config_id
;
112 #define SEL_RECORD_ID 0x01
113 #define SEL_PCIE_DEV_ERR 0x20
114 #define SEL_PCIE_IIO_ERR 0x23
115 #define SEL_PCIE_DEV_FAIL_ID 0x29
117 /* PCIE Unified Messages */
120 #define RECEIVER_ERROR 0x00
122 #define BAD_DLLP 0x02
123 #define REPLAY_TIME_OUT 0x03
124 #define REPLAY_NUMBER_ROLLOVER 0x04
125 #define ADVISORY_NONFATAL_ERROR_STATUS 0x05
126 #define CORRECTED_INTERNAL_ERROR_STATUS 0x06
127 #define HEADER_LOG_OVERFLOW_STATUS 0x07
130 #define PCI_EXPRESS_DATA_LINK_PROTOCOL_ERROR 0x20
131 #define SURPRISE_DOWN_ERROR 0x21
132 #define RECEIVED_PCI_EXPRESS_POISONED_TLP 0x22
133 #define PCI_EXPRESS_FLOW_CONTROL_PROTOCOL_ERROR 0x23
134 #define COMPLETION_TIMEOUT_ON_NP_TRANSACTIONS_OUTSTANDING_ON_PCI_EXPRESS_DMI 0x24
135 #define RECEIVED_A_REQUEST_FROM_A_DOWNSTREAM_COMPONENT_THAT_IS_TO_BE_COMPLETER_ABORTED 0x25
136 #define RECEIVED_PCI_EXPRESS_UNEXPECTED_COMPLETION 0x26
137 #define PCI_EXPRESS_RECEIVER_OVERFLOW 0x27
138 #define PCI_EXPRESS_MALFORMED_TLP 0x28
139 #define ECRC_ERROR_STATUS 0x29
140 #define RECEIVED_A_REQUEST_FROM_A_DOWNSTREAM_COMPONENT_THAT_IS_UNSUPPORTED 0x2A
141 #define ACS_VIOLATION 0x2B
142 #define UNCORRECTABLE_INTERNAL_ERROR_STATUS 0x2C
143 #define MC_BLOCKED_TLP 0x2D
144 #define ATOMICOP_EGRESS_BLOCKED_STATUS 0x2E
145 #define TLP_PREFIX_BLOCKED_ERROR_STATUS 0x2F
146 #define POISONED_TLP_EGRESS_BLOCKED 0x30
148 /* Root error status (from PCIE spec) */
149 #define RECEIVED_ERR_COR_MESSAGE_FROM_DOWNSTREAM_DEVICE 0x50
150 #define RECEIVED_ERR_NONFATAL_MESSAGE_FROM_DOWNSTREAM_DEVICE 0x51
151 #define RECEIVED_ERR_FATAL_MESSAGE_FROM_DOWNSTREAM_DEVICE 0x52
153 /* DPC Trigger Reason */
154 #define DPC_WAS_TRIGGERED_DUE_TO_AN_UNMASKED_UNCORRECTABLE_ERROR 0x53
155 #define DPC_WAS_TRIGGERED_DUE_TO_RECEIVING_AN_ERR_NONFATAL 0x54
156 #define DPC_WAS_TRIGGERED_DUE_TO_RECEIVING_AN_ERR_FATAL 0x55
157 #define DPC_WAS_TRIGGERED_DUE_TO_RP_PIO_ERROR 0x56
158 #define DPC_WAS_TRIGGERED_DUE_TO_THE_DPC_SOFTWARE_TRIGGER_BIT 0x57
160 #define OUTBOUND_SWITCH_FIFO_DATA_PARITY_ERROR_DETECTED 0x80
161 #define SENT_A_PCI_EXPRESS_COMPLETER_ABORT 0x81
162 #define SENT_A_PCI_EXPRESS_UNSUPPORTED_REQUEST 0x82
163 #define RECEIVED_COMPLETER_ABORT 0x83
164 #define RECEIVED_UNSUPPORTED_REQUEST_COMPLETION_STATUS_FROM_DOWNSTREAM_DEVICE 0x84
165 #define RECEIVED_MSI_WRITES_GREATER_THAN_A_DWORD 0x85
166 #define OUTBOUND_POISONED_DATA 0x86
167 #define PERR_NON_AER 0xA0
168 #define SERR_NON_AER 0xA1
170 enum cb_err
ipmi_set_post_start(const int port
);
171 enum cb_err
ipmi_set_cmos_clear(void);
173 void ipmi_send_to_bmc(unsigned char *data
, size_t size
);
174 void ipmi_send_sel_pcie_dev_err(pci_devfn_t bdf
, uint16_t prmry_cnt
, uint8_t sec_id
,
176 void ipmi_send_sel_pcie_dev_fail(uint16_t sts_reg
, uint16_t src_id
, enum fail_type code
);
177 void ipmi_send_sel_iio_err(uint8_t iio_stack_num
, uint8_t err_id
);
179 enum cb_err
ipmi_get_board_config(const int port
, struct ipmi_config_rsp
*config
);
180 uint8_t get_blade_id(void);