blob: fa19e01f418a603e4dad4787e9d36028387391cd [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +08002/*
3 * Copyright (C) 2006 Intel Corp.
4 * Tom Long Nguyen (tom.l.nguyen@intel.com)
5 * Zhang Yanmin (yanmin.zhang@intel.com)
6 */
7
8#ifndef _AER_H_
9#define _AER_H_
10
Sudip Mukherjeec89e5b82015-12-23 21:05:26 +053011#include <linux/errno.h>
Thierry Redingefd01a72014-08-05 14:08:55 +020012#include <linux/types.h>
13
Betty Dall9e50a912013-06-06 12:10:49 -060014#define AER_NONFATAL 0
15#define AER_FATAL 1
16#define AER_CORRECTABLE 2
Oza Pawandeepb09803b2018-05-17 16:44:20 -050017#define DPC_FATAL 3
Betty Dall9e50a912013-06-06 12:10:49 -060018
Mike Qiu5ccb8222014-07-29 10:49:25 -070019struct pci_dev;
20
Huang Yingc413d762011-02-21 13:54:43 +080021struct aer_header_log_regs {
22 unsigned int dw0;
23 unsigned int dw1;
24 unsigned int dw2;
25 unsigned int dw3;
26};
27
28struct aer_capability_regs {
29 u32 header;
30 u32 uncor_status;
31 u32 uncor_mask;
32 u32 uncor_severity;
33 u32 cor_status;
34 u32 cor_mask;
35 u32 cap_control;
36 struct aer_header_log_regs header_log;
37 u32 root_command;
38 u32 root_status;
39 u16 cor_err_source;
40 u16 uncor_err_source;
41};
42
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080043#if defined(CONFIG_PCIEAER)
Bjorn Helgaas96291d52017-09-01 16:35:50 -050044/* PCIe port driver needs this function to enable AER */
Betty Dallfde41b92013-06-06 14:35:35 -060045int pci_enable_pcie_error_reporting(struct pci_dev *dev);
46int pci_disable_pcie_error_reporting(struct pci_dev *dev);
47int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
Taku Izumib07461a2015-09-17 10:09:37 -050048int pci_cleanup_aer_error_status_regs(struct pci_dev *dev);
Patel, Mayurkumaraf65d1a2019-10-18 16:52:21 +000049void pci_save_aer_state(struct pci_dev *dev);
50void pci_restore_aer_state(struct pci_dev *dev);
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080051#else
Randy Dunlap5547bbe2007-08-23 10:37:53 -070052static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
53{
54 return -EINVAL;
55}
Randy Dunlap5547bbe2007-08-23 10:37:53 -070056static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev)
57{
58 return -EINVAL;
59}
60static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
61{
62 return -EINVAL;
63}
Taku Izumib07461a2015-09-17 10:09:37 -050064static inline int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
65{
66 return -EINVAL;
67}
Patel, Mayurkumaraf65d1a2019-10-18 16:52:21 +000068static inline void pci_save_aer_state(struct pci_dev *dev) {}
69static inline void pci_restore_aer_state(struct pci_dev *dev) {}
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080070#endif
71
Tyler Baicar95c35492016-09-14 15:14:45 -060072void cper_print_aer(struct pci_dev *dev, int aer_severity,
Betty Dallfde41b92013-06-06 14:35:35 -060073 struct aer_capability_regs *aer);
74int cper_severity_to_aer(int cper_severity);
75void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
Bjorn Helgaas96291d52017-09-01 16:35:50 -050076 int severity, struct aer_capability_regs *aer_regs);
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080077#endif //_AER_H_
78