2 * Copyright (C) 2006 Intel Corp.
3 * Tom Long Nguyen (tom.l.nguyen@intel.com)
4 * Zhang Yanmin (yanmin.zhang@intel.com)
11 #include <linux/workqueue.h>
12 #include <linux/pcieport_if.h>
13 #include <linux/aer.h>
14 #include <linux/interrupt.h>
16 #define AER_NONFATAL 0
18 #define AER_CORRECTABLE 2
20 /* Root Error Status Register Bits */
21 #define ROOT_ERR_STATUS_MASKS 0x0f
23 #define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
24 PCI_EXP_RTCTL_SENFEE| \
26 #define ROOT_PORT_INTR_ON_MESG_MASK (PCI_ERR_ROOT_CMD_COR_EN| \
27 PCI_ERR_ROOT_CMD_NONFATAL_EN| \
28 PCI_ERR_ROOT_CMD_FATAL_EN)
29 #define ERR_COR_ID(d) (d & 0xffff)
30 #define ERR_UNCOR_ID(d) (d >> 16)
32 #define AER_ERROR_SOURCES_MAX 100
34 #define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
37 PCI_ERR_UNC_COMP_ABORT| \
38 PCI_ERR_UNC_UNX_COMP| \
41 struct header_log_regs
{
48 #define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */
50 struct pci_dev
*dev
[AER_MAX_MULTI_ERR_DEVICES
];
55 unsigned int severity
:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
56 unsigned int __pad1
:5;
57 unsigned int multi_error_valid
:1;
59 unsigned int first_error
:5;
60 unsigned int __pad2
:2;
61 unsigned int tlp_header_valid
:1;
63 unsigned int status
; /* COR/UNCOR Error Status */
64 unsigned int mask
; /* COR/UNCOR Error Mask */
65 struct header_log_regs tlp
; /* TLP Header */
68 struct aer_err_source
{
74 struct pcie_device
*rpd
; /* Root Port device */
75 struct work_struct dpc_handler
;
76 struct aer_err_source e_sources
[AER_ERROR_SOURCES_MAX
];
77 unsigned short prod_idx
; /* Error Producer Index */
78 unsigned short cons_idx
; /* Error Consumer Index */
81 * Lock access to Error Status/ID Regs
82 * and error producer/consumer index
84 struct mutex rpc_mutex
; /*
85 * only one thread could do
86 * recovery on the same
89 wait_queue_head_t wait_release
;
92 struct aer_broadcast_data
{
93 enum pci_channel_state state
;
94 enum pci_ers_result result
;
97 static inline pci_ers_result_t
merge_result(enum pci_ers_result orig
,
98 enum pci_ers_result
new)
100 if (new == PCI_ERS_RESULT_NONE
)
104 case PCI_ERS_RESULT_CAN_RECOVER
:
105 case PCI_ERS_RESULT_RECOVERED
:
108 case PCI_ERS_RESULT_DISCONNECT
:
109 if (new == PCI_ERS_RESULT_NEED_RESET
)
119 extern struct bus_type pcie_port_bus_type
;
120 extern void aer_enable_rootport(struct aer_rpc
*rpc
);
121 extern void aer_delete_rootport(struct aer_rpc
*rpc
);
122 extern int aer_init(struct pcie_device
*dev
);
123 extern void aer_isr(struct work_struct
*work
);
124 extern void aer_print_error(struct pci_dev
*dev
, struct aer_err_info
*info
);
125 extern void aer_print_port_info(struct pci_dev
*dev
, struct aer_err_info
*info
);
126 extern irqreturn_t
aer_irq(int irq
, void *context
);
129 extern int aer_osc_setup(struct pcie_device
*pciedev
);
131 static inline int aer_osc_setup(struct pcie_device
*pciedev
)
137 #endif /* _AERDRV_H_ */