10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1865Sdilpreet * Common Development and Distribution License (the "License"). 6*1865Sdilpreet * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1865Sdilpreet * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _PCI_FM_H 270Sstevel@tonic-gate #define _PCI_FM_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/ddifm.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef _KERNEL 380Sstevel@tonic-gate 390Sstevel@tonic-gate #define PBM_PRIMARY 1 400Sstevel@tonic-gate #define PBM_SECONDARY 0 410Sstevel@tonic-gate #define PBM_NONFATAL 0 420Sstevel@tonic-gate #define PBM_FATAL 1 430Sstevel@tonic-gate #define CB_NONFATAL 0 440Sstevel@tonic-gate #define CB_FATAL 1 450Sstevel@tonic-gate #define FM_LOG_PCI 0 460Sstevel@tonic-gate #define FM_LOG_PBM 1 470Sstevel@tonic-gate #define PCI_SIDEA 0 480Sstevel@tonic-gate #define PCI_SIDEB 1 490Sstevel@tonic-gate #define ECC_MAX_ERRS 6 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * Since pci_pbm_err_handler() is called by various interrupt/trap/callback 530Sstevel@tonic-gate * handlers, it is necessary for it to know where it is being called from. 540Sstevel@tonic-gate * Below are the flags passed to pci_pbm_err_handler() to give it knowledge 550Sstevel@tonic-gate * of it's caller. 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate #define PCI_TRAP_CALL 0x0 580Sstevel@tonic-gate #define PCI_CB_CALL 0x1 590Sstevel@tonic-gate #define PCI_INTR_CALL 0x2 600Sstevel@tonic-gate #define PCI_BUS_EXIT_CALL 0x3 610Sstevel@tonic-gate #define PCI_ECC_CALL 0x4 620Sstevel@tonic-gate 630Sstevel@tonic-gate #define PCIX_ERROR_SUBCLASS "pcix" 640Sstevel@tonic-gate #define PCIX_SECONDARY "s-" 650Sstevel@tonic-gate #define PCIX_STAT "pcix-stat" 660Sstevel@tonic-gate #define PCIX_PFAR "pcix-pfar" 670Sstevel@tonic-gate 680Sstevel@tonic-gate extern errorq_t *pci_ecc_queue; /* per-system ecc handling queue */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * region where schizo pio ecc error was detected 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate typedef enum { 740Sstevel@tonic-gate SCH_REG_UPA, 750Sstevel@tonic-gate SCH_REG_PCIA_REG, 760Sstevel@tonic-gate SCH_REG_PCIA_MEM, 770Sstevel@tonic-gate SCH_REG_PCIA_CFGIO, 780Sstevel@tonic-gate SCH_REG_PCIB_REG, 790Sstevel@tonic-gate SCH_REG_PCIB_MEM, 800Sstevel@tonic-gate SCH_REG_PCIB_CFGIO, 810Sstevel@tonic-gate SCH_REG_SAFARI_REGS 820Sstevel@tonic-gate } ecc_region_t; 830Sstevel@tonic-gate 840Sstevel@tonic-gate typedef struct pbm_fm_err { 850Sstevel@tonic-gate char *pbm_err_class; 860Sstevel@tonic-gate uint64_t pbm_reg_bit; 870Sstevel@tonic-gate int pbm_pri; 880Sstevel@tonic-gate int pbm_flag; 890Sstevel@tonic-gate char *pbm_terr_class; 900Sstevel@tonic-gate } pbm_fm_err_t; 910Sstevel@tonic-gate 920Sstevel@tonic-gate typedef struct ecc_format { 930Sstevel@tonic-gate ecc_region_t ecc_region; 940Sstevel@tonic-gate uint64_t ecc_space; 950Sstevel@tonic-gate int ecc_side; 960Sstevel@tonic-gate } ecc_format_t; 970Sstevel@tonic-gate 980Sstevel@tonic-gate typedef struct cb_fm_err { 990Sstevel@tonic-gate char *cb_err_class; 1000Sstevel@tonic-gate uint64_t cb_reg_bit; 1010Sstevel@tonic-gate int cb_fatal; 1020Sstevel@tonic-gate } cb_fm_err_t; 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate typedef struct ecc_fm_err { 1050Sstevel@tonic-gate char *ecc_err_class; 1060Sstevel@tonic-gate uint64_t ecc_reg_bit; 1070Sstevel@tonic-gate int ecc_type; 1080Sstevel@tonic-gate int ecc_pri; 1090Sstevel@tonic-gate uint64_t ecc_region_bits; 1100Sstevel@tonic-gate int ecc_region; 1110Sstevel@tonic-gate int ecc_flag; 1120Sstevel@tonic-gate } ecc_fm_err_t; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * iommu errstate used to store iommu specific registers 1160Sstevel@tonic-gate */ 1170Sstevel@tonic-gate struct iommu_errstate { 1180Sstevel@tonic-gate uint64_t iommu_stat; 1190Sstevel@tonic-gate uint64_t iommu_tfar; 1200Sstevel@tonic-gate }; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate struct pci_errstate { 1230Sstevel@tonic-gate char *pci_err_class; 1240Sstevel@tonic-gate uint16_t pci_cfg_stat; 1250Sstevel@tonic-gate uint16_t pci_cfg_comm; 1260Sstevel@tonic-gate uint64_t pci_pa; 1270Sstevel@tonic-gate }; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* 1300Sstevel@tonic-gate * pbm errstate use to encompass the state for all errors 1310Sstevel@tonic-gate * detected by the pci block 1320Sstevel@tonic-gate */ 1330Sstevel@tonic-gate struct pbm_errstate { 1340Sstevel@tonic-gate char *pbm_err_class; 1350Sstevel@tonic-gate int pbm_pri; 1360Sstevel@tonic-gate int pbm_log; 1370Sstevel@tonic-gate uint32_t pbm_err; 1380Sstevel@tonic-gate uint32_t pbm_multi; 1390Sstevel@tonic-gate char *pbm_bridge_type; 1400Sstevel@tonic-gate uint64_t pbm_ctl_stat; 1410Sstevel@tonic-gate uint64_t pbm_afsr; 1420Sstevel@tonic-gate uint64_t pbm_afar; 1430Sstevel@tonic-gate uint64_t pbm_va_log; 1440Sstevel@tonic-gate uint64_t pbm_err_sl; 1450Sstevel@tonic-gate iommu_errstate_t pbm_iommu; 1460Sstevel@tonic-gate uint64_t pbm_pcix_stat; 1470Sstevel@tonic-gate uint32_t pbm_pcix_pfar; 1480Sstevel@tonic-gate pci_errstate_t pbm_pci; 1490Sstevel@tonic-gate char *pbm_terr_class; 1500Sstevel@tonic-gate }; 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate /* 1530Sstevel@tonic-gate * ecc errstate used to store all state captured, 1540Sstevel@tonic-gate * upon detection of an ecc error. 1550Sstevel@tonic-gate */ 1560Sstevel@tonic-gate struct ecc_errstate { 1570Sstevel@tonic-gate char *ecc_bridge_type; 1580Sstevel@tonic-gate ecc_t *ecc_p; 1590Sstevel@tonic-gate uint64_t ecc_afsr; 1600Sstevel@tonic-gate uint64_t ecc_afar; 1610Sstevel@tonic-gate uint64_t ecc_offset; 1620Sstevel@tonic-gate uint64_t ecc_dev_id; 1630Sstevel@tonic-gate uint64_t ecc_dw_offset; 1640Sstevel@tonic-gate struct async_flt ecc_aflt; 1650Sstevel@tonic-gate ecc_intr_info_t ecc_ii_p; 1660Sstevel@tonic-gate uint64_t ecc_ctrl; 1670Sstevel@tonic-gate int ecc_pri; 1680Sstevel@tonic-gate ecc_region_t ecc_region; 1690Sstevel@tonic-gate uint64_t ecc_ena; 1700Sstevel@tonic-gate uint64_t ecc_err_addr; 1710Sstevel@tonic-gate char *ecc_err_type; 1720Sstevel@tonic-gate int ecc_pg_ret; 1731186Sayznaga int ecc_caller; 1740Sstevel@tonic-gate nvlist_t *ecc_fmri; 1751186Sayznaga uint64_t ecc_dimm_offset; 1761186Sayznaga char ecc_unum[UNUM_NAMLEN]; 1771186Sayznaga char ecc_dimm_sid[DIMM_SERIAL_ID_LEN]; 1780Sstevel@tonic-gate }; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate /* 1810Sstevel@tonic-gate * control block error state 1820Sstevel@tonic-gate */ 1830Sstevel@tonic-gate struct cb_errstate { 1840Sstevel@tonic-gate char *cb_err_class; 1850Sstevel@tonic-gate char *cb_bridge_type; 1860Sstevel@tonic-gate uint64_t cb_csr; 1870Sstevel@tonic-gate uint64_t cb_err; 1880Sstevel@tonic-gate uint64_t cb_intr; 1890Sstevel@tonic-gate uint64_t cb_elog; 1900Sstevel@tonic-gate uint64_t cb_ecc; 1910Sstevel@tonic-gate uint64_t cb_pcr; 1920Sstevel@tonic-gate uint64_t cb_ue_afsr; 1930Sstevel@tonic-gate uint64_t cb_ue_afar; 1940Sstevel@tonic-gate uint64_t cb_ce_afsr; 1950Sstevel@tonic-gate uint64_t cb_ce_afar; 1960Sstevel@tonic-gate uint64_t cb_first_elog; 1970Sstevel@tonic-gate uint64_t cb_first_eaddr; 1980Sstevel@tonic-gate uint64_t cb_leaf_status; 1990Sstevel@tonic-gate pbm_errstate_t cb_pbm[2]; 2000Sstevel@tonic-gate }; 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate extern int pci_fm_init_child(dev_info_t *dip, dev_info_t *tdip, int cap, 2030Sstevel@tonic-gate ddi_iblock_cookie_t *ibc); 2040Sstevel@tonic-gate extern void pci_bus_enter(dev_info_t *dip, ddi_acc_handle_t handle); 2050Sstevel@tonic-gate extern void pci_bus_exit(dev_info_t *dip, ddi_acc_handle_t handle); 2060Sstevel@tonic-gate extern void pbm_ereport_post(dev_info_t *dip, uint64_t ena, 2070Sstevel@tonic-gate pbm_errstate_t *pbm_err); 2080Sstevel@tonic-gate extern void pci_fm_acc_setup(ddi_map_req_t *mp, dev_info_t *rdip); 2090Sstevel@tonic-gate extern void pci_fmri_create(dev_info_t *dip, pci_common_t *cmn_p); 2100Sstevel@tonic-gate extern void pci_fm_create(pci_t *pci_p); 2110Sstevel@tonic-gate extern void pci_fm_destroy(pci_t *pci_p); 2120Sstevel@tonic-gate extern int pci_err_callback(dev_info_t *dip, ddi_fm_error_t *derr, 2130Sstevel@tonic-gate const void *impl_data); 2140Sstevel@tonic-gate #endif /* _KERNEL */ 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate #ifdef __cplusplus 2170Sstevel@tonic-gate } 2180Sstevel@tonic-gate #endif 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate #endif /* _PCI_FM_H */ 221