16 #include <linux/module.h>
17 #include <linux/pci.h>
18 #include <linux/kernel.h>
19 #include <linux/errno.h>
26 #define AER_AGENT_RECEIVER 0
27 #define AER_AGENT_REQUESTER 1
28 #define AER_AGENT_COMPLETER 2
29 #define AER_AGENT_TRANSMITTER 3
31 #define AER_AGENT_REQUESTER_MASK(t) ((t == AER_CORRECTABLE) ? \
32 0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
33 #define AER_AGENT_COMPLETER_MASK(t) ((t == AER_CORRECTABLE) ? \
34 0 : PCI_ERR_UNC_COMP_ABORT)
35 #define AER_AGENT_TRANSMITTER_MASK(t) ((t == AER_CORRECTABLE) ? \
36 (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
38 #define AER_GET_AGENT(t, e) \
39 ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER : \
40 (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER : \
41 (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER : \
44 #define AER_PHYSICAL_LAYER_ERROR 0
45 #define AER_DATA_LINK_LAYER_ERROR 1
46 #define AER_TRANSACTION_LAYER_ERROR 2
48 #define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
50 #define AER_DATA_LINK_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
51 (PCI_ERR_COR_BAD_TLP| \
52 PCI_ERR_COR_BAD_DLLP| \
53 PCI_ERR_COR_REP_ROLL| \
54 PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
56 #define AER_GET_LAYER_ERROR(t, e) \
57 ((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
58 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
59 AER_TRANSACTION_LAYER_ERROR)
64 static const char *aer_error_severity_string[] = {
65 "Uncorrected (Non-Fatal)",
66 "Uncorrected (Fatal)",
70 static const char *aer_error_layer[] = {
76 static const char *aer_correctable_error_string[] = {
89 "Replay Timer Timeout",
93 static const char *aer_uncorrectable_error_string[] = {
107 "Flow Control Protocol",
108 "Completion Timeout",
110 "Unexpected Completion",
114 "Unsupported Request",
117 static const char *aer_agent_string[] = {
124 static void __aer_print_error(
const char *
prefix,
128 const char *errmsg =
NULL;
132 for (i = 0; i < 32; i++) {
133 if (!(status & (1 << i)))
137 errmsg = i <
ARRAY_SIZE(aer_correctable_error_string) ?
138 aer_correctable_error_string[
i] :
NULL;
140 errmsg = i <
ARRAY_SIZE(aer_uncorrectable_error_string) ?
141 aer_uncorrectable_error_string[
i] :
NULL;
144 printk(
"%s"" [%2d] %-22s%s\n", prefix, i, errmsg,
147 printk(
"%s"" [%2d] Unknown Error Bit%s\n", prefix, i,
154 int id = ((dev->
bus->number << 8) | dev->
devfn);
157 snprintf(prefix,
sizeof(prefix),
"%s%s %s: ",
162 printk(
"%s""PCIe Bus Error: severity=%s, type=Unaccessible, "
163 "id=%04x(Unregistered Agent ID)\n", prefix,
164 aer_error_severity_string[info->
severity],
id);
171 printk(
"%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
172 prefix, aer_error_severity_string[info->
severity],
173 aer_error_layer[layer],
id, aer_agent_string[agent]);
175 printk(
"%s"" device [%04x:%04x] error status/mask=%08x/%08x\n",
179 __aer_print_error(prefix, info);
182 unsigned char *tlp = (
unsigned char *) &info->
tlp;
184 " %02x%02x%02x%02x %02x%02x%02x%02x"
185 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
186 prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
187 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
188 *(tlp + 11), *(tlp + 10), *(tlp + 9),
189 *(tlp + 8), *(tlp + 15), *(tlp + 14),
190 *(tlp + 13), *(tlp + 12));
195 printk(
"%s"" Error of this Agent(%04x) is reported first\n",
201 dev_info(&dev->
dev,
"AER: %s%s error received: id=%04x\n",
203 aer_error_severity_string[info->
severity], info->
id);
206 #ifdef CONFIG_ACPI_APEI_PCIEAER
209 switch (cper_severity) {
223 int aer_severity, layer, agent, status_strs_size, tlp_header_valid = 0;
225 const char **status_strs;
231 status_strs = aer_correctable_error_string;
232 status_strs_size =
ARRAY_SIZE(aer_correctable_error_string);
236 status_strs = aer_uncorrectable_error_string;
237 status_strs_size =
ARRAY_SIZE(aer_uncorrectable_error_string);
242 printk(
"%s""aer_status: 0x%08x, aer_mask: 0x%08x\n",
243 prefix, status, mask);
245 printk(
"%s""aer_layer=%s, aer_agent=%s\n", prefix,
246 aer_error_layer[layer], aer_agent_string[agent]);
248 printk(
"%s""aer_uncor_severity: 0x%08x\n",
250 if (tlp_header_valid) {
251 const unsigned char *tlp;
252 tlp = (
const unsigned char *)&aer->
header_log;
253 printk(
"%s""aer_tlp_header:"
254 " %02x%02x%02x%02x %02x%02x%02x%02x"
255 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
256 prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
257 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
258 *(tlp + 11), *(tlp + 10), *(tlp + 9),
259 *(tlp + 8), *(tlp + 15), *(tlp + 14),
260 *(tlp + 13), *(tlp + 12));