127Sjchu /* 227Sjchu * CDDL HEADER START 327Sjchu * 427Sjchu * The contents of this file are subject to the terms of the 52549Sgovinda * Common Development and Distribution License (the "License"). 62549Sgovinda * You may not use this file except in compliance with the License. 727Sjchu * 827Sjchu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 927Sjchu * or http://www.opensolaris.org/os/licensing. 1027Sjchu * See the License for the specific language governing permissions 1127Sjchu * and limitations under the License. 1227Sjchu * 1327Sjchu * When distributing Covered Code, include this CDDL HEADER in each 1427Sjchu * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1527Sjchu * If applicable, add the following below this CDDL HEADER, with the 1627Sjchu * fields enclosed by brackets "[]" replaced with your own identifying 1727Sjchu * information: Portions Copyright [yyyy] [name of copyright owner] 1827Sjchu * 1927Sjchu * CDDL HEADER END 2027Sjchu */ 2127Sjchu /* 226313Skrishnae * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2327Sjchu * Use is subject to license terms. 2427Sjchu */ 2527Sjchu 2627Sjchu #ifndef _SYS_PCIE_IMPL_H 2727Sjchu #define _SYS_PCIE_IMPL_H 2827Sjchu 2927Sjchu #ifdef __cplusplus 3027Sjchu extern "C" { 3127Sjchu #endif 3227Sjchu 333274Set142600 #include <sys/pcie.h> 343274Set142600 356313Skrishnae #define PCI_GET_BDF(dip) \ 366313Skrishnae PCIE_DIP2BUS(dip)->bus_bdf 376313Skrishnae #define PCI_GET_SEC_BUS(dip) \ 386313Skrishnae PCIE_DIP2BUS(dip)->bus_bdg_secbus 396313Skrishnae #define PCI_GET_PCIE2PCI_SECBUS(dip) \ 406313Skrishnae PCIE_DIP2BUS(dip)->bus_pcie2pci_secbus 413274Set142600 426313Skrishnae #define DEVI_PORT_TYPE_PCI \ 436313Skrishnae ((PCI_CLASS_BRIDGE << 16) | (PCI_BRIDGE_PCI << 8) | \ 446313Skrishnae PCI_BRIDGE_PCI_IF_PCI2PCI) 453274Set142600 466313Skrishnae #define PCIE_DIP2BUS(dip) \ 476313Skrishnae (ndi_port_type(dip, B_TRUE, DEVI_PORT_TYPE_PCI) ? \ 486313Skrishnae PCIE_DIP2UPBUS(dip) : \ 496313Skrishnae ndi_port_type(dip, B_FALSE, DEVI_PORT_TYPE_PCI) ? \ 506313Skrishnae PCIE_DIP2DOWNBUS(dip) : NULL) 513274Set142600 526313Skrishnae #define PCIE_DIP2UPBUS(dip) \ 536313Skrishnae ((pcie_bus_t *)ndi_get_bus_private(dip, B_TRUE)) 546313Skrishnae #define PCIE_DIP2DOWNBUS(dip) \ 556313Skrishnae ((pcie_bus_t *)ndi_get_bus_private(dip, B_FALSE)) 566313Skrishnae #define PCIE_DIP2PFD(dip) (PCIE_DIP2BUS(dip))->bus_pfd 576313Skrishnae #define PCIE_PFD2BUS(pfd_p) pfd_p->pe_bus_p 586313Skrishnae #define PCIE_PFD2DIP(pfd_p) PCIE_PFD2BUS(pfd_p)->bus_dip 596313Skrishnae #define PCIE_BUS2DIP(bus_p) bus_p->bus_dip 606313Skrishnae #define PCIE_BUS2PFD(bus_p) PCIE_DIP2PFD(PCIE_BUS2DIP(bus_p)) 613274Set142600 626313Skrishnae #define PCIE_IS_PCIE(bus_p) (bus_p->bus_pcie_off) 636313Skrishnae #define PCIE_IS_PCIX(bus_p) (bus_p->bus_pcix_off) 646313Skrishnae #define PCIE_IS_PCI(bus_p) \ 656313Skrishnae (bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_PCI_DEV) 666313Skrishnae #define PCIE_HAS_AER(bus_p) (bus_p->bus_aer_off) 676313Skrishnae /* IS_ROOT = is RC or RP */ 686313Skrishnae #define PCIE_IS_ROOT(bus_p) (PCIE_IS_RC(bus_p) || PCIE_IS_RP(bus_p)) 696313Skrishnae /* 706313Skrishnae * This is a pseudo pcie "device type", but it's needed to explain describe 716313Skrishnae * nodes such as PX and NPE, which aren't really PCI devices but do control or 726313Skrishnae * interaction with PCI error handling. 736313Skrishnae */ 746313Skrishnae #define PCIE_IS_RC(bus_p) \ 756313Skrishnae (bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_RC_PSEUDO) 766313Skrishnae #define PCIE_IS_RP(bus_p) \ 776313Skrishnae ((bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_ROOT) && \ 786313Skrishnae PCIE_IS_PCIE(bus_p)) 796313Skrishnae #define PCIE_IS_SW(bus_p) \ 806313Skrishnae ((bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_UP) || \ 816313Skrishnae (bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_DOWN)) 826313Skrishnae #define PCIE_IS_BDG(bus_p) (bus_p->bus_hdr_type == PCI_HEADER_ONE) 836313Skrishnae #define PCIE_IS_PCI_BDG(bus_p) \ 846313Skrishnae ((bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_PCI_DEV) && \ 856313Skrishnae PCIE_IS_BDG(bus_p)) 866313Skrishnae #define PCIE_IS_PCIE_BDG(bus_p) \ 876313Skrishnae (bus_p->bus_dev_type == PCIE_PCIECAP_DEV_TYPE_PCIE2PCI) 886313Skrishnae #define PCIE_IS_PCIE_SEC(bus_p) \ 896313Skrishnae (PCIE_IS_PCIE(bus_p) && PCIE_IS_BDG(bus_p) && !PCIE_IS_PCIE_BDG(bus_p)) 906313Skrishnae #define PCIX_ECC_VERSION_CHECK(bus_p) \ 916313Skrishnae ((bus_p->bus_ecc_ver == PCI_PCIX_VER_1) || \ 926313Skrishnae (bus_p->bus_ecc_ver == PCI_PCIX_VER_2)) 933274Set142600 946313Skrishnae #define PCIE_VENID(bus_p) (bus_p->bus_dev_ven_id & 0xffff) 956313Skrishnae #define PCIE_DEVID(bus_p) ((bus_p->bus_dev_ven_id >> 16) & 0xffff) 963274Set142600 976313Skrishnae /* PCIE Cap/AER shortcuts */ 986313Skrishnae #define PCIE_GET(sz, bus_p, off) \ 996313Skrishnae pci_config_get ## sz(bus_p->bus_cfg_hdl, off) 1006313Skrishnae #define PCIE_PUT(sz, bus_p, off, val) \ 1016313Skrishnae pci_config_put ## sz(bus_p->bus_cfg_hdl, off, val) 1026313Skrishnae #define PCIE_CAP_GET(sz, bus_p, off) \ 1036313Skrishnae PCI_CAP_GET ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_pcie_off, off) 1046313Skrishnae #define PCIE_CAP_PUT(sz, bus_p, off, val) \ 1056313Skrishnae PCI_CAP_PUT ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_pcie_off, off, \ 1066313Skrishnae val) 1076313Skrishnae #define PCIE_AER_GET(sz, bus_p, off) \ 1086313Skrishnae PCI_XCAP_GET ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_aer_off, off) 1096313Skrishnae #define PCIE_AER_PUT(sz, bus_p, off, val) \ 1106313Skrishnae PCI_XCAP_PUT ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_aer_off, off, \ 1116313Skrishnae val) 1126313Skrishnae #define PCIX_CAP_GET(sz, bus_p, off) \ 1136313Skrishnae PCI_CAP_GET ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_pcix_off, off) 1146313Skrishnae #define PCIX_CAP_PUT(sz, bus_p, off, val) \ 1156313Skrishnae PCI_CAP_PUT ## sz(bus_p->bus_cfg_hdl, NULL, bus_p->bus_pcix_off, off, \ 1166313Skrishnae val) 1173274Set142600 1186313Skrishnae /* Translate PF error return values to DDI_FM values */ 1196313Skrishnae #define PF_ERR2DDIFM_ERR(sts) \ 1206313Skrishnae (sts & PF_ERR_FATAL_FLAGS ? DDI_FM_FATAL : \ 1216313Skrishnae (sts == PF_ERR_NO_ERROR ? DDI_FM_OK : DDI_FM_NONFATAL)) 1223274Set142600 12327Sjchu /* 1242549Sgovinda * The following flag is used for Broadcom 5714/5715 bridge prefetch issue. 1252549Sgovinda * This flag will be used both by px and px_pci nexus drivers. 1262549Sgovinda */ 1272549Sgovinda #define PX_DMAI_FLAGS_MAP_BUFZONE 0x40000 1282549Sgovinda 1296313Skrishnae /* 1306313Skrishnae * PCI(e/-X) structures used to to gather and report errors detected by 1316313Skrishnae * PCI(e/-X) compliant devices. These registers only contain "dynamic" data. 1326313Skrishnae * Static data such as Capability Offsets and Version #s is saved in the parent 1336313Skrishnae * private data. 1346313Skrishnae */ 1356313Skrishnae #define PCI_ERR_REG(pfd_p) pfd_p->pe_pci_regs 1366313Skrishnae #define PCI_BDG_ERR_REG(pfd_p) PCI_ERR_REG(pfd_p)->pci_bdg_regs 1376313Skrishnae #define PCIX_ERR_REG(pfd_p) pfd_p->pe_ext.pe_pcix_regs 1386313Skrishnae #define PCIX_ECC_REG(pfd_p) PCIX_ERR_REG(pfd_p)->pcix_ecc_regs 1396313Skrishnae #define PCIX_BDG_ERR_REG(pfd_p) pfd_p->pe_pcix_bdg_regs 1406313Skrishnae #define PCIX_BDG_ECC_REG(pfd_p, n) PCIX_BDG_ERR_REG(pfd_p)->pcix_bdg_ecc_regs[n] 1416313Skrishnae #define PCIE_ERR_REG(pfd_p) pfd_p->pe_ext.pe_pcie_regs 1426313Skrishnae #define PCIE_RP_REG(pfd_p) PCIE_ERR_REG(pfd_p)->pcie_rp_regs 1436313Skrishnae #define PCIE_ROOT_FAULT(pfd_p) pfd_p->pe_root_fault 1446313Skrishnae #define PCIE_ADV_REG(pfd_p) PCIE_ERR_REG(pfd_p)->pcie_adv_regs 1456313Skrishnae #define PCIE_ADV_HDR(pfd_p, n) PCIE_ADV_REG(pfd_p)->pcie_ue_hdr[n] 1466313Skrishnae #define PCIE_ADV_BDG_REG(pfd_p) \ 1476313Skrishnae PCIE_ADV_REG(pfd_p)->pcie_ext.pcie_adv_bdg_regs 1486313Skrishnae #define PCIE_ADV_BDG_HDR(pfd_p, n) PCIE_ADV_BDG_REG(pfd_p)->pcie_sue_hdr[n] 1496313Skrishnae #define PCIE_ADV_RP_REG(pfd_p) \ 1506313Skrishnae PCIE_ADV_REG(pfd_p)->pcie_ext.pcie_adv_rp_regs 1516313Skrishnae #define PFD_IS_ROOT(pfd_p) PCIE_IS_ROOT(PCIE_PFD2BUS(pfd_p)) 1526313Skrishnae #define PFD_IS_RC(pfd_p) PCIE_IS_RC(PCIE_PFD2BUS(pfd_p)) 1536313Skrishnae #define PFD_IS_RP(pfd_p) PCIE_IS_RP(PCIE_PFD2BUS(pfd_p)) 1546313Skrishnae 1556313Skrishnae typedef struct pf_pci_bdg_err_regs { 1566313Skrishnae uint16_t pci_bdg_sec_stat; /* PCI secondary status reg */ 1576313Skrishnae uint16_t pci_bdg_ctrl; /* PCI bridge control reg */ 1586313Skrishnae } pf_pci_bdg_err_regs_t; 1596313Skrishnae 1606313Skrishnae typedef struct pf_pci_err_regs { 1616313Skrishnae uint16_t pci_err_status; /* pci status register */ 1626313Skrishnae uint16_t pci_cfg_comm; /* pci command register */ 1636313Skrishnae pf_pci_bdg_err_regs_t *pci_bdg_regs; 1646313Skrishnae } pf_pci_err_regs_t; 1656313Skrishnae 1666313Skrishnae typedef struct pf_pcix_ecc_regs { 1676313Skrishnae uint32_t pcix_ecc_ctlstat; /* pcix ecc control status reg */ 1686313Skrishnae uint32_t pcix_ecc_fstaddr; /* pcix ecc first address reg */ 1696313Skrishnae uint32_t pcix_ecc_secaddr; /* pcix ecc second address reg */ 1706313Skrishnae uint32_t pcix_ecc_attr; /* pcix ecc attributes reg */ 1716313Skrishnae } pf_pcix_ecc_regs_t; 1723274Set142600 1736313Skrishnae typedef struct pf_pcix_err_regs { 1746313Skrishnae uint16_t pcix_command; /* pcix command register */ 1756313Skrishnae uint32_t pcix_status; /* pcix status register */ 1766313Skrishnae pf_pcix_ecc_regs_t *pcix_ecc_regs; /* pcix ecc registers */ 1776313Skrishnae } pf_pcix_err_regs_t; 1786313Skrishnae 1796313Skrishnae typedef struct pf_pcix_bdg_err_regs { 1806313Skrishnae uint16_t pcix_bdg_sec_stat; /* pcix bridge secondary status reg */ 1816313Skrishnae uint32_t pcix_bdg_stat; /* pcix bridge status reg */ 1826313Skrishnae pf_pcix_ecc_regs_t *pcix_bdg_ecc_regs[2]; /* pcix ecc registers */ 1836313Skrishnae } pf_pcix_bdg_err_regs_t; 1846313Skrishnae 1856313Skrishnae typedef struct pf_pcie_adv_bdg_err_regs { 1866313Skrishnae uint32_t pcie_sue_ctl; /* pcie bridge secondary ue control */ 1876313Skrishnae uint32_t pcie_sue_status; /* pcie bridge secondary ue status */ 1886313Skrishnae uint32_t pcie_sue_mask; /* pcie bridge secondary ue mask */ 1896313Skrishnae uint32_t pcie_sue_sev; /* pcie bridge secondary ue severity */ 1906313Skrishnae uint32_t pcie_sue_hdr[4]; /* pcie bridge secondary ue hdr log */ 1916313Skrishnae uint32_t pcie_sue_tgt_trans; /* Fault trans type from SAER Logs */ 1926313Skrishnae uint64_t pcie_sue_tgt_addr; /* Fault addr from SAER Logs */ 1936313Skrishnae pcie_req_id_t pcie_sue_tgt_bdf; /* Fault bdf from SAER Logs */ 1946313Skrishnae } pf_pcie_adv_bdg_err_regs_t; 1953274Set142600 1966313Skrishnae typedef struct pf_pcie_adv_rp_err_regs { 1976313Skrishnae uint32_t pcie_rp_err_status; /* pcie root complex error status reg */ 1986313Skrishnae uint32_t pcie_rp_err_cmd; /* pcie root complex error cmd reg */ 1996313Skrishnae uint16_t pcie_rp_ce_src_id; /* pcie root complex ce sourpe id */ 2006313Skrishnae uint16_t pcie_rp_ue_src_id; /* pcie root complex ue sourpe id */ 2016313Skrishnae } pf_pcie_adv_rp_err_regs_t; 2026313Skrishnae 2036313Skrishnae typedef struct pf_pcie_adv_err_regs { 2046313Skrishnae uint32_t pcie_adv_ctl; /* pcie advanced control reg */ 2056313Skrishnae uint32_t pcie_ue_status; /* pcie ue error status reg */ 2066313Skrishnae uint32_t pcie_ue_mask; /* pcie ue error mask reg */ 2076313Skrishnae uint32_t pcie_ue_sev; /* pcie ue error severity reg */ 2086313Skrishnae uint32_t pcie_ue_hdr[4]; /* pcie ue header log */ 2096313Skrishnae uint32_t pcie_ce_status; /* pcie ce error status reg */ 2106313Skrishnae uint32_t pcie_ce_mask; /* pcie ce error mask reg */ 2116313Skrishnae union { 2126313Skrishnae pf_pcie_adv_bdg_err_regs_t *pcie_adv_bdg_regs; /* bdg regs */ 2136313Skrishnae pf_pcie_adv_rp_err_regs_t *pcie_adv_rp_regs; /* rp regs */ 2146313Skrishnae } pcie_ext; 2156313Skrishnae uint32_t pcie_ue_tgt_trans; /* Fault trans type from AER Logs */ 2166313Skrishnae uint64_t pcie_ue_tgt_addr; /* Fault addr from AER Logs */ 2176313Skrishnae pcie_req_id_t pcie_ue_tgt_bdf; /* Fault bdf from SAER Logs */ 2186313Skrishnae } pf_pcie_adv_err_regs_t; 2196313Skrishnae 2206313Skrishnae typedef struct pf_pcie_rp_err_regs { 2216313Skrishnae uint32_t pcie_rp_status; /* root complex status register */ 2226313Skrishnae uint16_t pcie_rp_ctl; /* root complex control register */ 2236313Skrishnae } pf_pcie_rp_err_regs_t; 2243274Set142600 2256313Skrishnae typedef struct pf_pcie_err_regs { 2266313Skrishnae uint16_t pcie_err_status; /* pcie device status register */ 2276313Skrishnae uint16_t pcie_err_ctl; /* pcie error control register */ 2286313Skrishnae uint32_t pcie_dev_cap; /* pcie device capabilities register */ 2296313Skrishnae pf_pcie_rp_err_regs_t *pcie_rp_regs; /* pcie root complex regs */ 2306313Skrishnae pf_pcie_adv_err_regs_t *pcie_adv_regs; /* pcie aer regs */ 2316313Skrishnae } pf_pcie_err_regs_t; 2326313Skrishnae 2336313Skrishnae typedef struct pf_root_fault { 2346313Skrishnae pcie_req_id_t fault_bdf; /* Fault BDF of error */ 2356313Skrishnae uint64_t fault_addr; /* Fault Addr of error */ 2366313Skrishnae boolean_t full_scan; /* Option to do a full scan */ 2376313Skrishnae } pf_root_fault_t; 2386313Skrishnae 2396313Skrishnae typedef struct pf_data pf_data_t; 2406313Skrishnae 2416313Skrishnae typedef struct pcie_bus { 2426313Skrishnae /* Needed for PCI/PCIe fabric error handling */ 2436313Skrishnae dev_info_t *bus_dip; 2446313Skrishnae dev_info_t *bus_rp_dip; 2456313Skrishnae ddi_acc_handle_t bus_cfg_hdl; /* error handling acc handle */ 2466313Skrishnae uint_t bus_fm_flags; 2476313Skrishnae 2486313Skrishnae /* Static PCI/PCIe information */ 2496313Skrishnae pcie_req_id_t bus_bdf; 2506313Skrishnae pcie_req_id_t bus_rp_bdf; /* BDF of device's Root Port */ 2516313Skrishnae uint32_t bus_dev_ven_id; /* device/vendor ID */ 2526313Skrishnae uint8_t bus_rev_id; /* revision ID */ 2536313Skrishnae uint8_t bus_hdr_type; /* pci header type, see pci.h */ 2546313Skrishnae pcie_req_id_t bus_pcie2pci_secbus; /* PCIe2PCI Bridge secbus num */ 2556313Skrishnae uint16_t bus_dev_type; /* PCI-E dev type, see pcie.h */ 2566313Skrishnae uint8_t bus_bdg_secbus; /* Bridge secondary bus num */ 2576313Skrishnae uint16_t bus_pcie_off; /* PCIe Capability Offset */ 2586313Skrishnae uint16_t bus_aer_off; /* PCIe Advanced Error Offset */ 2596313Skrishnae uint16_t bus_pcix_off; /* PCIx Capability Offset */ 2606313Skrishnae uint16_t bus_ecc_ver; /* PCIX ecc version */ 2616313Skrishnae pci_bus_range_t bus_bus_range; /* pci bus-range property */ 2626313Skrishnae ppb_ranges_t *bus_addr_ranges; /* pci range property */ 2636313Skrishnae int bus_addr_entries; /* number of range prop */ 2646313Skrishnae pci_regspec_t *bus_assigned_addr; /* "assigned-address" prop */ 2656313Skrishnae int bus_assigned_entries; /* number of prop entries */ 2666313Skrishnae 2676313Skrishnae /* Cache of last fault data */ 2686313Skrishnae pf_data_t *bus_pfd; 2697596SAlan.Adamson@Sun.COM 2707596SAlan.Adamson@Sun.COM int bus_mps; /* Maximum Payload Size */ 2716313Skrishnae } pcie_bus_t; 2723274Set142600 2736313Skrishnae struct pf_data { 2746313Skrishnae boolean_t pe_lock; 2756313Skrishnae boolean_t pe_valid; 2766313Skrishnae uint32_t pe_severity_flags; /* Severity of error */ 2776313Skrishnae pcie_bus_t *pe_bus_p; 2786313Skrishnae pf_root_fault_t *pe_root_fault; /* Only valid for RC and RP */ 2796313Skrishnae pf_pci_err_regs_t *pe_pci_regs; /* PCI error reg */ 2806313Skrishnae union { 2816313Skrishnae pf_pcix_err_regs_t *pe_pcix_regs; /* PCI-X error reg */ 2826313Skrishnae pf_pcie_err_regs_t *pe_pcie_regs; /* PCIe error reg */ 2836313Skrishnae } pe_ext; 2846313Skrishnae pf_pcix_bdg_err_regs_t *pe_pcix_bdg_regs; /* PCI-X bridge regs */ 2856313Skrishnae pf_data_t *pe_prev; /* Next error in queue */ 2866313Skrishnae pf_data_t *pe_next; /* Next error in queue */ 287*7848SKrishna.Elango@Sun.COM boolean_t pe_rber_fatal; 2886313Skrishnae }; 2896313Skrishnae 2906313Skrishnae /* Information used while handling errors in the fabric. */ 2916313Skrishnae typedef struct pf_impl { 2926313Skrishnae ddi_fm_error_t *pf_derr; 2936313Skrishnae pf_root_fault_t *pf_fault; /* captured fault bdf/addr to scan */ 2946313Skrishnae pf_data_t *pf_dq_head_p; /* ptr to fault data queue */ 2956313Skrishnae pf_data_t *pf_dq_tail_p; /* ptr pt last fault data q */ 2966313Skrishnae uint32_t pf_total; /* total non RC pf_datas */ 2976313Skrishnae } pf_impl_t; 2986313Skrishnae 2996313Skrishnae /* bus_fm_flags field */ 3006313Skrishnae #define PF_FM_READY (1 << 0) /* bus_fm_lock initialized */ 3016313Skrishnae #define PF_FM_IS_NH (1 << 1) /* known as non-hardened */ 3023274Set142600 3036313Skrishnae /* 3046313Skrishnae * PCIe fabric handle lookup address flags. Used to define what type of 3056313Skrishnae * transaction the address is for. These same value are defined again in 3066313Skrishnae * fabric-xlate FM module. Do not modify these variables, without modifying 3076313Skrishnae * those. 3086313Skrishnae */ 3096313Skrishnae #define PF_ADDR_DMA (1 << 0) 3106313Skrishnae #define PF_ADDR_PIO (1 << 1) 3116313Skrishnae #define PF_ADDR_CFG (1 << 2) 3123274Set142600 3136313Skrishnae /* PCIe fabric error scanning status flags */ 3146313Skrishnae #define PF_SCAN_SUCCESS (1 << 0) 3156313Skrishnae #define PF_SCAN_CB_FAILURE (1 << 1) /* hardened device callback failure */ 3166313Skrishnae #define PF_SCAN_NO_ERR_IN_CHILD (1 << 2) /* no errors in bridge sec stat reg */ 3176313Skrishnae #define PF_SCAN_IN_DQ (1 << 3) /* already present in the faultq */ 3186313Skrishnae #define PF_SCAN_DEADLOCK (1 << 4) /* deadlock detected */ 3196313Skrishnae #define PF_SCAN_BAD_RESPONSE (1 << 5) /* Incorrect device response */ 3206313Skrishnae 3216313Skrishnae /* PCIe fabric error handling severity return flags */ 3226313Skrishnae #define PF_ERR_NO_ERROR (1 << 0) /* No error seen */ 3236313Skrishnae #define PF_ERR_CE (1 << 1) /* Correctable Error */ 3246313Skrishnae #define PF_ERR_NO_PANIC (1 << 2) /* Error should not panic sys */ 3256313Skrishnae #define PF_ERR_MATCHED_DEVICE (1 << 3) /* Error Handled By Device */ 3266313Skrishnae #define PF_ERR_MATCHED_RC (1 << 4) /* Error Handled By RC */ 3276313Skrishnae #define PF_ERR_MATCHED_PARENT (1 << 5) /* Error Handled By Parent */ 3286313Skrishnae #define PF_ERR_PANIC (1 << 6) /* Error should panic system */ 3296313Skrishnae #define PF_ERR_PANIC_DEADLOCK (1 << 7) /* deadlock detected */ 3306313Skrishnae 3316313Skrishnae #define PF_ERR_FATAL_FLAGS (PF_ERR_PANIC | PF_ERR_PANIC_DEADLOCK) 3326313Skrishnae 3336313Skrishnae #define PF_HDL_FOUND 1 3346313Skrishnae #define PF_HDL_NOTFOUND 2 3356313Skrishnae 3366313Skrishnae #define PCIE_PCIECAP_DEV_TYPE_RC_PSEUDO 0x100 3373274Set142600 3387596SAlan.Adamson@Sun.COM typedef struct { 3397596SAlan.Adamson@Sun.COM dev_info_t *dip; 3407596SAlan.Adamson@Sun.COM int highest_common_mps; 3417596SAlan.Adamson@Sun.COM } pcie_max_supported_t; 3427596SAlan.Adamson@Sun.COM 3433274Set142600 /* PCIe Friendly Functions */ 34427Sjchu extern int pcie_initchild(dev_info_t *dip); 34527Sjchu extern void pcie_uninitchild(dev_info_t *dip); 3466313Skrishnae extern void pcie_clear_errors(dev_info_t *dip); 3472738Skrishnae extern int pcie_postattach_child(dev_info_t *dip); 3486313Skrishnae extern void pcie_enable_errors(dev_info_t *dip); 3496313Skrishnae extern void pcie_disable_errors(dev_info_t *dip); 3506313Skrishnae extern int pcie_enable_ce(dev_info_t *dip); 3516313Skrishnae extern boolean_t pcie_bridge_is_link_disabled(dev_info_t *); 3526313Skrishnae 3536313Skrishnae extern pcie_bus_t *pcie_init_bus(dev_info_t *cdip); 3546313Skrishnae extern void pcie_fini_bus(dev_info_t *cdip); 3556313Skrishnae extern void pcie_rc_init_bus(dev_info_t *dip); 3566313Skrishnae extern void pcie_rc_fini_bus(dev_info_t *dip); 3576313Skrishnae extern void pcie_rc_init_pfd(dev_info_t *dip, pf_data_t *pfd); 3586313Skrishnae extern void pcie_rc_fini_pfd(pf_data_t *pfd); 3596313Skrishnae extern boolean_t pcie_is_child(dev_info_t *dip, dev_info_t *rdip); 3606313Skrishnae extern int pcie_get_bdf_from_dip(dev_info_t *dip, pcie_req_id_t *bdf); 3613156Sgirish extern dev_info_t *pcie_get_my_childs_dip(dev_info_t *dip, dev_info_t *rdip); 3623249Sgovinda extern uint32_t pcie_get_bdf_for_dma_xfer(dev_info_t *dip, dev_info_t *rdip); 3637596SAlan.Adamson@Sun.COM extern int pcie_dev(dev_info_t *dip); 3647596SAlan.Adamson@Sun.COM extern void pcie_get_fabric_mps(dev_info_t *rc_dip, dev_info_t *dip, 3657596SAlan.Adamson@Sun.COM int *max_supported); 3667596SAlan.Adamson@Sun.COM extern int pcie_root_port(dev_info_t *dip); 3677596SAlan.Adamson@Sun.COM extern int pcie_initchild_mps(dev_info_t *dip); 368*7848SKrishna.Elango@Sun.COM extern void pcie_set_rber_fatal(dev_info_t *dip, boolean_t val); 369*7848SKrishna.Elango@Sun.COM extern boolean_t pcie_get_rber_fatal(dev_info_t *dip); 3703274Set142600 3716313Skrishnae extern uint32_t pcie_get_aer_uce_mask(); 3726313Skrishnae extern uint32_t pcie_get_aer_ce_mask(); 3736313Skrishnae extern uint32_t pcie_get_aer_suce_mask(); 3746313Skrishnae extern uint32_t pcie_get_serr_mask(); 3756313Skrishnae extern void pcie_set_aer_uce_mask(uint32_t mask); 3766313Skrishnae extern void pcie_set_aer_ce_mask(uint32_t mask); 3776313Skrishnae extern void pcie_set_aer_suce_mask(uint32_t mask); 3786313Skrishnae extern void pcie_set_serr_mask(uint32_t mask); 3793274Set142600 3803274Set142600 /* PCIe error handling functions */ 3813274Set142600 extern int pf_scan_fabric(dev_info_t *rpdip, ddi_fm_error_t *derr, 3826313Skrishnae pf_data_t *root_pfd_p); 3836313Skrishnae extern void pf_init(dev_info_t *, ddi_iblock_cookie_t, ddi_attach_cmd_t); 3846313Skrishnae extern void pf_fini(dev_info_t *, ddi_detach_cmd_t); 3856313Skrishnae extern int pf_hdl_lookup(dev_info_t *, uint64_t, uint32_t, uint64_t, 3866313Skrishnae pcie_req_id_t); 3876313Skrishnae extern int pf_tlp_decode(pcie_bus_t *, pf_pcie_adv_err_regs_t *); 38827Sjchu 38927Sjchu #ifdef __cplusplus 39027Sjchu } 39127Sjchu #endif 39227Sjchu 39327Sjchu #endif /* _SYS_PCIE_IMPL_H */ 394