xref: /linux-6.15/include/linux/aer.h (revision 7e077e67)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
26c2b374dSZhang, Yanmin /*
36c2b374dSZhang, Yanmin  * Copyright (C) 2006 Intel Corp.
46c2b374dSZhang, Yanmin  *     Tom Long Nguyen ([email protected])
56c2b374dSZhang, Yanmin  *     Zhang Yanmin ([email protected])
66c2b374dSZhang, Yanmin  */
76c2b374dSZhang, Yanmin 
86c2b374dSZhang, Yanmin #ifndef _AER_H_
96c2b374dSZhang, Yanmin #define _AER_H_
106c2b374dSZhang, Yanmin 
11c89e5b80SSudip Mukherjee #include <linux/errno.h>
12efd01a72SThierry Reding #include <linux/types.h>
13efd01a72SThierry Reding 
149e50a912SBetty Dall #define AER_NONFATAL			0
159e50a912SBetty Dall #define AER_FATAL			1
169e50a912SBetty Dall #define AER_CORRECTABLE			2
17b09803b5SOza Pawandeep #define DPC_FATAL			3
189e50a912SBetty Dall 
19ede5d5dbSIlpo Järvinen /*
20ede5d5dbSIlpo Järvinen  * AER and DPC capabilities TLP Logging register sizes (PCIe r6.2, sec 7.8.4
21ede5d5dbSIlpo Järvinen  * & 7.9.14).
22ede5d5dbSIlpo Järvinen  */
23ede5d5dbSIlpo Järvinen #define PCIE_STD_NUM_TLP_HEADERLOG     4
24ede5d5dbSIlpo Järvinen #define PCIE_STD_MAX_TLP_PREFIXLOG     4
25*7e077e67SIlpo Järvinen #define PCIE_STD_MAX_TLP_HEADERLOG	(PCIE_STD_NUM_TLP_HEADERLOG + 10)
26ede5d5dbSIlpo Järvinen 
275ccb8225SMike Qiu struct pci_dev;
285ccb8225SMike Qiu 
290a5a46a6SIlpo Järvinen struct pcie_tlp_log {
30*7e077e67SIlpo Järvinen 	union {
31*7e077e67SIlpo Järvinen 		u32 dw[PCIE_STD_MAX_TLP_HEADERLOG];
32*7e077e67SIlpo Järvinen 		struct {
33*7e077e67SIlpo Järvinen 			u32 _do_not_use[PCIE_STD_NUM_TLP_HEADERLOG];
34ad41ddeeSIlpo Järvinen 			u32 prefix[PCIE_STD_MAX_TLP_PREFIXLOG];
35c413d768SHuang Ying 		};
36*7e077e67SIlpo Järvinen 	};
37*7e077e67SIlpo Järvinen 	u8 header_len;		/* Length of the Logged TLP Header in DWORDs */
38*7e077e67SIlpo Järvinen 	bool flit;		/* TLP was logged when in Flit mode */
39*7e077e67SIlpo Järvinen };
40c413d768SHuang Ying 
41c413d768SHuang Ying struct aer_capability_regs {
42c413d768SHuang Ying 	u32 header;
43c413d768SHuang Ying 	u32 uncor_status;
44c413d768SHuang Ying 	u32 uncor_mask;
45c413d768SHuang Ying 	u32 uncor_severity;
46c413d768SHuang Ying 	u32 cor_status;
47c413d768SHuang Ying 	u32 cor_mask;
48c413d768SHuang Ying 	u32 cap_control;
490a5a46a6SIlpo Järvinen 	struct pcie_tlp_log header_log;
50c413d768SHuang Ying 	u32 root_command;
51c413d768SHuang Ying 	u32 root_status;
52c413d768SHuang Ying 	u16 cor_err_source;
53c413d768SHuang Ying 	u16 uncor_err_source;
54c413d768SHuang Ying };
55c413d768SHuang Ying 
566c2b374dSZhang, Yanmin #if defined(CONFIG_PCIEAER)
57894020fdSKuppuswamy Sathyanarayanan int pci_aer_clear_nonfatal_status(struct pci_dev *dev);
5849f77672SSmita Koralahalli int pcie_aer_is_native(struct pci_dev *dev);
596c2b374dSZhang, Yanmin #else
pci_aer_clear_nonfatal_status(struct pci_dev * dev)60894020fdSKuppuswamy Sathyanarayanan static inline int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
61b07461a8STaku Izumi {
62b07461a8STaku Izumi 	return -EINVAL;
63b07461a8STaku Izumi }
pcie_aer_is_native(struct pci_dev * dev)6449f77672SSmita Koralahalli static inline int pcie_aer_is_native(struct pci_dev *dev) { return 0; }
656c2b374dSZhang, Yanmin #endif
666c2b374dSZhang, Yanmin 
676777877eSTerry Bowman void pci_print_aer(struct pci_dev *dev, int aer_severity,
68fde41b9fSBetty Dall 		    struct aer_capability_regs *aer);
69fde41b9fSBetty Dall int cper_severity_to_aer(int cper_severity);
70fde41b9fSBetty Dall void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
7196291d56SBjorn Helgaas 		       int severity, struct aer_capability_regs *aer_regs);
726c2b374dSZhang, Yanmin #endif //_AER_H_
736c2b374dSZhang, Yanmin 
74