14df55fdeSJanie Lu /* 24df55fdeSJanie Lu * CDDL HEADER START 34df55fdeSJanie Lu * 44df55fdeSJanie Lu * The contents of this file are subject to the terms of the 54df55fdeSJanie Lu * Common Development and Distribution License (the "License"). 64df55fdeSJanie Lu * You may not use this file except in compliance with the License. 74df55fdeSJanie Lu * 84df55fdeSJanie Lu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 94df55fdeSJanie Lu * or http://www.opensolaris.org/os/licensing. 104df55fdeSJanie Lu * See the License for the specific language governing permissions 114df55fdeSJanie Lu * and limitations under the License. 124df55fdeSJanie Lu * 134df55fdeSJanie Lu * When distributing Covered Code, include this CDDL HEADER in each 144df55fdeSJanie Lu * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 154df55fdeSJanie Lu * If applicable, add the following below this CDDL HEADER, with the 164df55fdeSJanie Lu * fields enclosed by brackets "[]" replaced with your own identifying 174df55fdeSJanie Lu * information: Portions Copyright [yyyy] [name of copyright owner] 184df55fdeSJanie Lu * 194df55fdeSJanie Lu * CDDL HEADER END 204df55fdeSJanie Lu */ 214df55fdeSJanie Lu /* 22*4f764f91SCheng Sean Ye * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 234df55fdeSJanie Lu */ 244df55fdeSJanie Lu 254df55fdeSJanie Lu #ifndef _FABRIC_XLATE_H 264df55fdeSJanie Lu #define _FABRIC_XLATE_H 274df55fdeSJanie Lu 284df55fdeSJanie Lu #include <fm/fmd_api.h> 294df55fdeSJanie Lu #include <sys/fm/protocol.h> 304df55fdeSJanie Lu #include <sys/nvpair.h> 314df55fdeSJanie Lu #include <sys/types.h> 324df55fdeSJanie Lu #include <sys/pcie.h> 334df55fdeSJanie Lu #include <sys/fm/io/pci.h> 344df55fdeSJanie Lu 354df55fdeSJanie Lu #ifdef __cplusplus 364df55fdeSJanie Lu extern "C" { 374df55fdeSJanie Lu #endif 384df55fdeSJanie Lu 394df55fdeSJanie Lu #define STRCMP(s1, s2) (strcmp((const char *)s1, (const char *)s2) == 0) 404df55fdeSJanie Lu /* 414df55fdeSJanie Lu * These values are used for the xxx_tgt_trans value in fab_data_t. They are 424df55fdeSJanie Lu * originally set in pcie_fault.c and originally defined in pcie_impl.h. 434df55fdeSJanie Lu */ 444df55fdeSJanie Lu #define PF_ADDR_DMA (1 << 0) 454df55fdeSJanie Lu #define PF_ADDR_PIO (1 << 1) 464df55fdeSJanie Lu #define PF_ADDR_CFG (1 << 2) 474df55fdeSJanie Lu 484df55fdeSJanie Lu extern fmd_xprt_t *fab_fmd_xprt; /* FMD transport layer handle */ 494df55fdeSJanie Lu extern char fab_buf[]; 504df55fdeSJanie Lu 514df55fdeSJanie Lu /* PCI-E config space data for error handling and fabric ereports */ 524df55fdeSJanie Lu typedef struct fab_data { 534df55fdeSJanie Lu /* Original ereport NVL */ 544df55fdeSJanie Lu nvlist_t *nvl; 554df55fdeSJanie Lu 564df55fdeSJanie Lu /* Device Information */ 574df55fdeSJanie Lu uint16_t bdf; 584df55fdeSJanie Lu uint16_t device_id; 594df55fdeSJanie Lu uint16_t vendor_id; 604df55fdeSJanie Lu uint8_t rev_id; 614df55fdeSJanie Lu uint16_t dev_type; 624df55fdeSJanie Lu uint16_t pcie_off; 634df55fdeSJanie Lu uint16_t pcix_off; 644df55fdeSJanie Lu uint16_t aer_off; 654df55fdeSJanie Lu uint16_t ecc_ver; 664df55fdeSJanie Lu 674df55fdeSJanie Lu /* Ereport Information */ 684df55fdeSJanie Lu uint32_t remainder; 694df55fdeSJanie Lu uint32_t severity; 704df55fdeSJanie Lu 714df55fdeSJanie Lu /* Error Registers */ 724df55fdeSJanie Lu uint16_t pci_err_status; /* pci status register */ 734df55fdeSJanie Lu uint16_t pci_cfg_comm; /* pci command register */ 744df55fdeSJanie Lu 754df55fdeSJanie Lu uint16_t pci_bdg_sec_stat; /* PCI secondary status reg */ 764df55fdeSJanie Lu uint16_t pci_bdg_ctrl; /* PCI bridge control reg */ 774df55fdeSJanie Lu 784df55fdeSJanie Lu uint16_t pcix_command; /* pcix command register */ 794df55fdeSJanie Lu uint32_t pcix_status; /* pcix status register */ 804df55fdeSJanie Lu 814df55fdeSJanie Lu uint16_t pcix_bdg_sec_stat; /* pcix bridge secondary status reg */ 824df55fdeSJanie Lu uint32_t pcix_bdg_stat; /* pcix bridge status reg */ 834df55fdeSJanie Lu 844df55fdeSJanie Lu uint16_t pcix_ecc_control_0; /* pcix ecc control status reg */ 854df55fdeSJanie Lu uint16_t pcix_ecc_status_0; /* pcix ecc control status reg */ 864df55fdeSJanie Lu uint32_t pcix_ecc_fst_addr_0; /* pcix ecc first address reg */ 874df55fdeSJanie Lu uint32_t pcix_ecc_sec_addr_0; /* pcix ecc second address reg */ 884df55fdeSJanie Lu uint32_t pcix_ecc_attr_0; /* pcix ecc attributes reg */ 894df55fdeSJanie Lu uint16_t pcix_ecc_control_1; /* pcix ecc control status reg */ 904df55fdeSJanie Lu uint16_t pcix_ecc_status_1; /* pcix ecc control status reg */ 914df55fdeSJanie Lu uint32_t pcix_ecc_fst_addr_1; /* pcix ecc first address reg */ 924df55fdeSJanie Lu uint32_t pcix_ecc_sec_addr_1; /* pcix ecc second address reg */ 934df55fdeSJanie Lu uint32_t pcix_ecc_attr_1; /* pcix ecc attributes reg */ 944df55fdeSJanie Lu 954df55fdeSJanie Lu uint16_t pcie_err_status; /* pcie device status register */ 964df55fdeSJanie Lu uint16_t pcie_err_ctl; /* pcie error control register */ 974df55fdeSJanie Lu uint32_t pcie_dev_cap; /* pcie device capabilities register */ 984df55fdeSJanie Lu 994df55fdeSJanie Lu uint32_t pcie_adv_ctl; /* pcie advanced control reg */ 1004df55fdeSJanie Lu uint32_t pcie_ue_status; /* pcie ue error status reg */ 1014df55fdeSJanie Lu uint32_t pcie_ue_mask; /* pcie ue error mask reg */ 1024df55fdeSJanie Lu uint32_t pcie_ue_sev; /* pcie ue error severity reg */ 1034df55fdeSJanie Lu uint32_t pcie_ue_hdr[4]; /* pcie ue header log */ 1044df55fdeSJanie Lu uint32_t pcie_ce_status; /* pcie ce error status reg */ 1054df55fdeSJanie Lu uint32_t pcie_ce_mask; /* pcie ce error mask reg */ 1064df55fdeSJanie Lu uint32_t pcie_ue_tgt_trans; /* Fault trans type from AER Logs */ 1074df55fdeSJanie Lu uint64_t pcie_ue_tgt_addr; /* Fault addr from AER Logs */ 1084df55fdeSJanie Lu pcie_req_id_t pcie_ue_tgt_bdf; /* Fault bdf from SAER Logs */ 1094df55fdeSJanie Lu boolean_t pcie_ue_no_tgt_erpt; /* Don't send target ereports */ 1104df55fdeSJanie Lu 1114df55fdeSJanie Lu uint32_t pcie_sue_ctl; /* pcie bridge secondary ue control */ 1124df55fdeSJanie Lu uint32_t pcie_sue_status; /* pcie bridge secondary ue status */ 1134df55fdeSJanie Lu uint32_t pcie_sue_mask; /* pcie bridge secondary ue mask */ 1144df55fdeSJanie Lu uint32_t pcie_sue_sev; /* pcie bridge secondary ue severity */ 1154df55fdeSJanie Lu uint32_t pcie_sue_hdr[4]; /* pcie bridge secondary ue hdr log */ 1164df55fdeSJanie Lu uint32_t pcie_sue_tgt_trans; /* Fault trans type from AER Logs */ 1174df55fdeSJanie Lu uint64_t pcie_sue_tgt_addr; /* Fault addr from AER Logs */ 1184df55fdeSJanie Lu pcie_req_id_t pcie_sue_tgt_bdf; /* Fault bdf from SAER Logs */ 1194df55fdeSJanie Lu 1204df55fdeSJanie Lu uint32_t pcie_rp_status; /* root complex status register */ 1214df55fdeSJanie Lu uint16_t pcie_rp_ctl; /* root complex control register */ 1224df55fdeSJanie Lu uint32_t pcie_rp_err_status; /* pcie root complex error status reg */ 1234df55fdeSJanie Lu uint32_t pcie_rp_err_cmd; /* pcie root complex error cmd reg */ 1244df55fdeSJanie Lu uint16_t pcie_rp_ce_src_id; /* pcie root complex ce sourpe id */ 1254df55fdeSJanie Lu uint16_t pcie_rp_ue_src_id; /* pcie root complex ue sourpe id */ 126036ec191SCheng Sean Ye 127036ec191SCheng Sean Ye /* Flags */ 128036ec191SCheng Sean Ye boolean_t pcie_rp_send_all; /* need to send ereports on all rps */ 1294df55fdeSJanie Lu } fab_data_t; 1304df55fdeSJanie Lu 1314df55fdeSJanie Lu typedef struct fab_erpt_tbl { 1324df55fdeSJanie Lu const char *err_class; /* Final Ereport Class */ 1334df55fdeSJanie Lu uint32_t reg_bit; /* Error Bit Mask */ 1344df55fdeSJanie Lu /* Pointer to function that prepares the ereport body */ 1354df55fdeSJanie Lu const char *tgt_class; /* Target Ereport Class */ 1364df55fdeSJanie Lu } fab_erpt_tbl_t; 1374df55fdeSJanie Lu 1384df55fdeSJanie Lu typedef struct fab_err_tbl { 1394df55fdeSJanie Lu fab_erpt_tbl_t *erpt_tbl; /* ereport table */ 1404df55fdeSJanie Lu uint32_t reg_offset; /* sts reg for ereport table offset */ 1414df55fdeSJanie Lu uint32_t reg_size; /* size of the status register */ 1424df55fdeSJanie Lu /* Pointer to function that prepares the ereport body */ 1434df55fdeSJanie Lu int (*fab_prep)(fmd_hdl_t *, fab_data_t *, nvlist_t *, 1444df55fdeSJanie Lu fab_erpt_tbl_t *); 1454df55fdeSJanie Lu } fab_err_tbl_t; 1464df55fdeSJanie Lu 1474df55fdeSJanie Lu extern void fab_setup_master_table(); 1484df55fdeSJanie Lu 1494df55fdeSJanie Lu /* Main functions for converting "fabric" ereports */ 1504df55fdeSJanie Lu extern void fab_xlate_pcie_erpts(fmd_hdl_t *, fab_data_t *); 1514df55fdeSJanie Lu extern void fab_xlate_fabric_erpts(fmd_hdl_t *, nvlist_t *, const char *); 1524df55fdeSJanie Lu extern void fab_xlate_fire_erpts(fmd_hdl_t *, nvlist_t *, const char *); 1534df55fdeSJanie Lu extern void fab_xlate_epkt_erpts(fmd_hdl_t *, nvlist_t *, const char *); 1544df55fdeSJanie Lu 1554df55fdeSJanie Lu /* Common functions for sending translated ereports */ 1564df55fdeSJanie Lu extern int fab_prep_basic_erpt(fmd_hdl_t *, nvlist_t *, nvlist_t *, boolean_t); 1574df55fdeSJanie Lu extern void fab_send_tgt_erpt(fmd_hdl_t *, fab_data_t *, const char *, 1584df55fdeSJanie Lu boolean_t); 1594df55fdeSJanie Lu extern void fab_send_erpt(fmd_hdl_t *hdl, fab_data_t *data, fab_err_tbl_t *tbl); 1604df55fdeSJanie Lu 1614df55fdeSJanie Lu /* Misc Functions */ 1624df55fdeSJanie Lu extern void fab_pr(fmd_hdl_t *, fmd_event_t *, nvlist_t *); 163036ec191SCheng Sean Ye extern boolean_t fab_get_hcpath(fmd_hdl_t *, nvlist_t *, char **, size_t *); 164036ec191SCheng Sean Ye extern boolean_t fab_get_rcpath(fmd_hdl_t *, nvlist_t *, char *); 1654df55fdeSJanie Lu extern char *fab_find_rppath_by_df(fmd_hdl_t *, nvlist_t *, uint8_t); 1664df55fdeSJanie Lu extern char *fab_find_rppath_by_devbdf(fmd_hdl_t *, nvlist_t *, pcie_req_id_t); 167*4f764f91SCheng Sean Ye extern char *fab_find_rppath_by_devpath(fmd_hdl_t *, const char *); 1684df55fdeSJanie Lu extern char *fab_find_addr(fmd_hdl_t *hdl, nvlist_t *nvl, uint64_t addr); 1694df55fdeSJanie Lu extern char *fab_find_bdf(fmd_hdl_t *hdl, nvlist_t *nvl, pcie_req_id_t bdf); 1704df55fdeSJanie Lu extern boolean_t fab_hc2dev(fmd_hdl_t *, const char *, char **); 1714df55fdeSJanie Lu extern boolean_t fab_hc2dev_nvl(fmd_hdl_t *, nvlist_t *, char **); 172036ec191SCheng Sean Ye extern char *fab_get_rpdev(fmd_hdl_t *); 173036ec191SCheng Sean Ye extern void fab_set_fake_rp(fmd_hdl_t *); 174036ec191SCheng Sean Ye extern void fab_send_erpt_all_rps(fmd_hdl_t *, nvlist_t *); 1754df55fdeSJanie Lu 1764df55fdeSJanie Lu #ifdef __cplusplus 1774df55fdeSJanie Lu } 1784df55fdeSJanie Lu #endif 1794df55fdeSJanie Lu 1804df55fdeSJanie Lu #endif /* _FABRIC_XLATE_H */ 181