xref: /illumos-gate/usr/src/uts/sun4u/sys/pci/pci_fm.h (revision 00d0963f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*00d0963fSdilpreet  * Common Development and Distribution License (the "License").
6*00d0963fSdilpreet  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*00d0963fSdilpreet  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_PCI_FM_H
277c478bd9Sstevel@tonic-gate #define	_PCI_FM_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/ddifm.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef _KERNEL
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	PBM_PRIMARY		1
407c478bd9Sstevel@tonic-gate #define	PBM_SECONDARY		0
417c478bd9Sstevel@tonic-gate #define	PBM_NONFATAL		0
427c478bd9Sstevel@tonic-gate #define	PBM_FATAL		1
437c478bd9Sstevel@tonic-gate #define	CB_NONFATAL		0
447c478bd9Sstevel@tonic-gate #define	CB_FATAL		1
457c478bd9Sstevel@tonic-gate #define	FM_LOG_PCI		0
467c478bd9Sstevel@tonic-gate #define	FM_LOG_PBM		1
477c478bd9Sstevel@tonic-gate #define	PCI_SIDEA		0
487c478bd9Sstevel@tonic-gate #define	PCI_SIDEB		1
497c478bd9Sstevel@tonic-gate #define	ECC_MAX_ERRS		6
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * Since pci_pbm_err_handler() is called by various interrupt/trap/callback
537c478bd9Sstevel@tonic-gate  * handlers, it is necessary for it to know where it is being called from.
547c478bd9Sstevel@tonic-gate  * Below are the flags passed to pci_pbm_err_handler() to give it knowledge
557c478bd9Sstevel@tonic-gate  * of it's caller.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate #define	PCI_TRAP_CALL		0x0
587c478bd9Sstevel@tonic-gate #define	PCI_CB_CALL		0x1
597c478bd9Sstevel@tonic-gate #define	PCI_INTR_CALL		0x2
607c478bd9Sstevel@tonic-gate #define	PCI_BUS_EXIT_CALL	0x3
617c478bd9Sstevel@tonic-gate #define	PCI_ECC_CALL		0x4
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate #define	PCIX_ERROR_SUBCLASS	"pcix"
647c478bd9Sstevel@tonic-gate #define	PCIX_SECONDARY		"s-"
657c478bd9Sstevel@tonic-gate #define	PCIX_STAT		"pcix-stat"
667c478bd9Sstevel@tonic-gate #define	PCIX_PFAR		"pcix-pfar"
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate extern errorq_t *pci_ecc_queue;		/* per-system ecc handling queue */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * region where schizo pio ecc error was detected
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate typedef enum {
747c478bd9Sstevel@tonic-gate 	SCH_REG_UPA,
757c478bd9Sstevel@tonic-gate 	SCH_REG_PCIA_REG,
767c478bd9Sstevel@tonic-gate 	SCH_REG_PCIA_MEM,
777c478bd9Sstevel@tonic-gate 	SCH_REG_PCIA_CFGIO,
787c478bd9Sstevel@tonic-gate 	SCH_REG_PCIB_REG,
797c478bd9Sstevel@tonic-gate 	SCH_REG_PCIB_MEM,
807c478bd9Sstevel@tonic-gate 	SCH_REG_PCIB_CFGIO,
817c478bd9Sstevel@tonic-gate 	SCH_REG_SAFARI_REGS
827c478bd9Sstevel@tonic-gate } ecc_region_t;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate typedef struct pbm_fm_err {
857c478bd9Sstevel@tonic-gate 	char *pbm_err_class;
867c478bd9Sstevel@tonic-gate 	uint64_t pbm_reg_bit;
877c478bd9Sstevel@tonic-gate 	int pbm_pri;
887c478bd9Sstevel@tonic-gate 	int pbm_flag;
897c478bd9Sstevel@tonic-gate 	char *pbm_terr_class;
907c478bd9Sstevel@tonic-gate } pbm_fm_err_t;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate typedef struct ecc_format {
937c478bd9Sstevel@tonic-gate 	ecc_region_t ecc_region;
947c478bd9Sstevel@tonic-gate 	uint64_t ecc_space;
957c478bd9Sstevel@tonic-gate 	int ecc_side;
967c478bd9Sstevel@tonic-gate } ecc_format_t;
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate typedef struct cb_fm_err {
997c478bd9Sstevel@tonic-gate 	char *cb_err_class;
1007c478bd9Sstevel@tonic-gate 	uint64_t cb_reg_bit;
1017c478bd9Sstevel@tonic-gate 	int cb_fatal;
1027c478bd9Sstevel@tonic-gate } cb_fm_err_t;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate typedef struct ecc_fm_err {
1057c478bd9Sstevel@tonic-gate 	char *ecc_err_class;
1067c478bd9Sstevel@tonic-gate 	uint64_t ecc_reg_bit;
1077c478bd9Sstevel@tonic-gate 	int ecc_type;
1087c478bd9Sstevel@tonic-gate 	int ecc_pri;
1097c478bd9Sstevel@tonic-gate 	uint64_t ecc_region_bits;
1107c478bd9Sstevel@tonic-gate 	int ecc_region;
1117c478bd9Sstevel@tonic-gate 	int ecc_flag;
1127c478bd9Sstevel@tonic-gate } ecc_fm_err_t;
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate  * iommu errstate used to store iommu specific registers
1167c478bd9Sstevel@tonic-gate  */
1177c478bd9Sstevel@tonic-gate struct iommu_errstate {
1187c478bd9Sstevel@tonic-gate 	uint64_t iommu_stat;
1197c478bd9Sstevel@tonic-gate 	uint64_t iommu_tfar;
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate struct pci_errstate {
1237c478bd9Sstevel@tonic-gate 	char *pci_err_class;
1247c478bd9Sstevel@tonic-gate 	uint16_t pci_cfg_stat;
1257c478bd9Sstevel@tonic-gate 	uint16_t pci_cfg_comm;
1267c478bd9Sstevel@tonic-gate 	uint64_t pci_pa;
1277c478bd9Sstevel@tonic-gate };
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * pbm errstate use to encompass the state for all errors
1317c478bd9Sstevel@tonic-gate  * detected by the pci block
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate struct pbm_errstate {
1347c478bd9Sstevel@tonic-gate 	char *pbm_err_class;
1357c478bd9Sstevel@tonic-gate 	int pbm_pri;
1367c478bd9Sstevel@tonic-gate 	int pbm_log;
1377c478bd9Sstevel@tonic-gate 	uint32_t pbm_err;
1387c478bd9Sstevel@tonic-gate 	uint32_t pbm_multi;
1397c478bd9Sstevel@tonic-gate 	char *pbm_bridge_type;
1407c478bd9Sstevel@tonic-gate 	uint64_t pbm_ctl_stat;
1417c478bd9Sstevel@tonic-gate 	uint64_t pbm_afsr;
1427c478bd9Sstevel@tonic-gate 	uint64_t pbm_afar;
1437c478bd9Sstevel@tonic-gate 	uint64_t pbm_va_log;
1447c478bd9Sstevel@tonic-gate 	uint64_t pbm_err_sl;
1457c478bd9Sstevel@tonic-gate 	iommu_errstate_t pbm_iommu;
1467c478bd9Sstevel@tonic-gate 	uint64_t pbm_pcix_stat;
1477c478bd9Sstevel@tonic-gate 	uint32_t pbm_pcix_pfar;
1487c478bd9Sstevel@tonic-gate 	pci_errstate_t pbm_pci;
1497c478bd9Sstevel@tonic-gate 	char *pbm_terr_class;
1507c478bd9Sstevel@tonic-gate };
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * ecc errstate used to store all state captured,
1547c478bd9Sstevel@tonic-gate  * upon detection of an ecc error.
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate struct ecc_errstate {
1577c478bd9Sstevel@tonic-gate 	char *ecc_bridge_type;
1587c478bd9Sstevel@tonic-gate 	ecc_t *ecc_p;
1597c478bd9Sstevel@tonic-gate 	uint64_t ecc_afsr;
1607c478bd9Sstevel@tonic-gate 	uint64_t ecc_afar;
1617c478bd9Sstevel@tonic-gate 	uint64_t ecc_offset;
1627c478bd9Sstevel@tonic-gate 	uint64_t ecc_dev_id;
1637c478bd9Sstevel@tonic-gate 	uint64_t ecc_dw_offset;
1647c478bd9Sstevel@tonic-gate 	struct async_flt ecc_aflt;
1657c478bd9Sstevel@tonic-gate 	ecc_intr_info_t ecc_ii_p;
1667c478bd9Sstevel@tonic-gate 	uint64_t ecc_ctrl;
1677c478bd9Sstevel@tonic-gate 	int ecc_pri;
1687c478bd9Sstevel@tonic-gate 	ecc_region_t ecc_region;
1697c478bd9Sstevel@tonic-gate 	uint64_t ecc_ena;
1707c478bd9Sstevel@tonic-gate 	uint64_t ecc_err_addr;
1717c478bd9Sstevel@tonic-gate 	char *ecc_err_type;
1727c478bd9Sstevel@tonic-gate 	int ecc_pg_ret;
1737c478bd9Sstevel@tonic-gate 	int ecc_caller;
174d00f0155Sayznaga 	nvlist_t *ecc_fmri;
175d00f0155Sayznaga 	uint64_t ecc_dimm_offset;
176d00f0155Sayznaga 	char ecc_unum[UNUM_NAMLEN];
177d00f0155Sayznaga 	char ecc_dimm_sid[DIMM_SERIAL_ID_LEN];
1787c478bd9Sstevel@tonic-gate };
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * control block error state
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate struct cb_errstate {
1847c478bd9Sstevel@tonic-gate 	char *cb_err_class;
1857c478bd9Sstevel@tonic-gate 	char *cb_bridge_type;
1867c478bd9Sstevel@tonic-gate 	uint64_t cb_csr;
1877c478bd9Sstevel@tonic-gate 	uint64_t cb_err;
1887c478bd9Sstevel@tonic-gate 	uint64_t cb_intr;
1897c478bd9Sstevel@tonic-gate 	uint64_t cb_elog;
1907c478bd9Sstevel@tonic-gate 	uint64_t cb_ecc;
1917c478bd9Sstevel@tonic-gate 	uint64_t cb_pcr;
1927c478bd9Sstevel@tonic-gate 	uint64_t cb_ue_afsr;
1937c478bd9Sstevel@tonic-gate 	uint64_t cb_ue_afar;
1947c478bd9Sstevel@tonic-gate 	uint64_t cb_ce_afsr;
1957c478bd9Sstevel@tonic-gate 	uint64_t cb_ce_afar;
1967c478bd9Sstevel@tonic-gate 	uint64_t cb_first_elog;
1977c478bd9Sstevel@tonic-gate 	uint64_t cb_first_eaddr;
1987c478bd9Sstevel@tonic-gate 	uint64_t cb_leaf_status;
1997c478bd9Sstevel@tonic-gate 	pbm_errstate_t cb_pbm[2];
2007c478bd9Sstevel@tonic-gate };
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate extern int pci_fm_init_child(dev_info_t *dip, dev_info_t *tdip, int cap,
2037c478bd9Sstevel@tonic-gate 		ddi_iblock_cookie_t *ibc);
2047c478bd9Sstevel@tonic-gate extern void pci_bus_enter(dev_info_t *dip, ddi_acc_handle_t handle);
2057c478bd9Sstevel@tonic-gate extern void pci_bus_exit(dev_info_t *dip, ddi_acc_handle_t handle);
2067c478bd9Sstevel@tonic-gate extern void pbm_ereport_post(dev_info_t *dip, uint64_t ena,
2077c478bd9Sstevel@tonic-gate 		pbm_errstate_t *pbm_err);
2087c478bd9Sstevel@tonic-gate extern void pci_fm_acc_setup(ddi_map_req_t *mp, dev_info_t *rdip);
2097c478bd9Sstevel@tonic-gate extern void pci_fmri_create(dev_info_t *dip, pci_common_t *cmn_p);
2107c478bd9Sstevel@tonic-gate extern void pci_fm_create(pci_t *pci_p);
2117c478bd9Sstevel@tonic-gate extern void pci_fm_destroy(pci_t *pci_p);
2127c478bd9Sstevel@tonic-gate extern int pci_err_callback(dev_info_t *dip, ddi_fm_error_t *derr,
2137c478bd9Sstevel@tonic-gate 		const void *impl_data);
2147c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2177c478bd9Sstevel@tonic-gate }
2187c478bd9Sstevel@tonic-gate #endif
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate #endif	/* _PCI_FM_H */
221