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 51865Sdilpreet * Common Development and Distribution License (the "License"). 61865Sdilpreet * 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 /* 226313Skrishnae * Copyright 2008 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 _DDIFM_IMPL_H 270Sstevel@tonic-gate #define _DDIFM_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/dditypes.h> 300Sstevel@tonic-gate #include <sys/errorq.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate struct i_ddi_fmkstat { 370Sstevel@tonic-gate kstat_named_t fek_erpt_dropped; /* total ereports dropped */ 38*7931SSean.Ye@Sun.COM kstat_named_t fek_fmc_miss; /* total fmc misses */ 39*7931SSean.Ye@Sun.COM kstat_named_t fek_fmc_full; /* total fmc allocs fail */ 400Sstevel@tonic-gate kstat_named_t fek_acc_err; /* total access errors */ 410Sstevel@tonic-gate kstat_named_t fek_dma_err; /* total dma errors */ 420Sstevel@tonic-gate }; 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* Fault management error handler support */ 450Sstevel@tonic-gate 460Sstevel@tonic-gate #define DDI_MAX_ERPT_CLASS 64 470Sstevel@tonic-gate #define DDI_FM_STKDEPTH 20 480Sstevel@tonic-gate #define DDI_FM_SYM_SZ 64 490Sstevel@tonic-gate 500Sstevel@tonic-gate struct i_ddi_errhdl { 510Sstevel@tonic-gate int (*eh_func)(); /* error handler callback */ 520Sstevel@tonic-gate void *eh_impl; /* callback arg */ 530Sstevel@tonic-gate }; 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* Fault management resource cache support */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate struct i_ddi_fmc_entry { 580Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_prev; 590Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_next; 600Sstevel@tonic-gate void *fce_resource; /* acc or DMA handle cached */ 610Sstevel@tonic-gate void *fce_bus_specific; /* Bus-specific handle data */ 620Sstevel@tonic-gate }; 630Sstevel@tonic-gate 640Sstevel@tonic-gate struct i_ddi_fmc { 653114Scindi kmutex_t fc_lock; /* cache active access */ 66*7931SSean.Ye@Sun.COM struct i_ddi_fmc_entry *fc_head; /* active handle list */ 670Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_tail; /* tail of active handle list */ 680Sstevel@tonic-gate }; 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* Error handler targets */ 710Sstevel@tonic-gate struct i_ddi_fmtgt { 720Sstevel@tonic-gate struct i_ddi_fmtgt *ft_next; /* next fm child target */ 730Sstevel@tonic-gate dev_info_t *ft_dip; /* fm target error handler dip */ 740Sstevel@tonic-gate struct i_ddi_errhdl *ft_errhdl; /* error handler */ 750Sstevel@tonic-gate }; 760Sstevel@tonic-gate 770Sstevel@tonic-gate struct i_ddi_fmhdl { 780Sstevel@tonic-gate kmutex_t fh_lock; /* error handler lock */ 796313Skrishnae kthread_t *fh_lock_owner; 800Sstevel@tonic-gate struct i_ddi_fmc *fh_dma_cache; /* fm dma handle cache */ 810Sstevel@tonic-gate struct i_ddi_fmc *fh_acc_cache; /* fm access handle cache */ 820Sstevel@tonic-gate dev_info_t *fh_dip; 830Sstevel@tonic-gate kstat_t *fh_ksp; /* pointer to installed kstat */ 840Sstevel@tonic-gate int fh_cap; /* fm level for this instance */ 850Sstevel@tonic-gate struct i_ddi_fmkstat fh_kstat; /* fm kstats for this inst */ 860Sstevel@tonic-gate errorq_t *fh_errorq; /* errorq for this instance */ 870Sstevel@tonic-gate nvlist_t *fh_fmri; /* optional fmri */ 880Sstevel@tonic-gate ddi_iblock_cookie_t fh_ibc; /* ibc for error handling */ 890Sstevel@tonic-gate struct i_ddi_fmtgt *fh_tgts; /* registered fm tgts */ 900Sstevel@tonic-gate void *fh_bus_specific; /* Bus specific FM info */ 910Sstevel@tonic-gate }; 920Sstevel@tonic-gate 930Sstevel@tonic-gate typedef struct pci_fm_err { 940Sstevel@tonic-gate char *err_class; 951865Sdilpreet uint32_t reg_bit; 960Sstevel@tonic-gate char *terr_class; 971865Sdilpreet int flags; 980Sstevel@tonic-gate } pci_fm_err_t; 990Sstevel@tonic-gate 1000Sstevel@tonic-gate extern pci_fm_err_t pci_err_tbl[]; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate #ifdef _KERNEL 1031865Sdilpreet typedef int (*ddi_fmcompare_t)(dev_info_t *, const void *, const void *, 1041865Sdilpreet const void *); 1050Sstevel@tonic-gate 106*7931SSean.Ye@Sun.COM extern void ndi_fm_init(void); 107*7931SSean.Ye@Sun.COM 1080Sstevel@tonic-gate /* driver defect error reporting */ 109*7931SSean.Ye@Sun.COM extern void i_ddi_drv_ereport_post(dev_info_t *, const char *, nvlist_t *, int); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* target error handler add/remove/dispatch */ 1120Sstevel@tonic-gate extern void i_ddi_fm_handler_enter(dev_info_t *); 1130Sstevel@tonic-gate extern void i_ddi_fm_handler_exit(dev_info_t *); 1146313Skrishnae extern boolean_t i_ddi_fm_handler_owned(dev_info_t *); 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* access and dma handle protection support */ 1170Sstevel@tonic-gate extern void i_ddi_fm_acc_err_set(ddi_acc_handle_t, uint64_t, int, int); 1180Sstevel@tonic-gate extern void i_ddi_fm_dma_err_set(ddi_dma_handle_t, uint64_t, int, int); 1191865Sdilpreet extern ddi_fmcompare_t i_ddi_fm_acc_err_cf_get(ddi_acc_handle_t); 1201865Sdilpreet extern ddi_fmcompare_t i_ddi_fm_dma_err_cf_get(ddi_dma_handle_t); 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* fm busop support */ 1230Sstevel@tonic-gate extern void i_ndi_busop_access_enter(dev_info_t *, ddi_acc_handle_t); 1240Sstevel@tonic-gate extern void i_ndi_busop_access_exit(dev_info_t *, ddi_acc_handle_t); 1250Sstevel@tonic-gate extern int i_ndi_busop_fm_init(dev_info_t *, int, ddi_iblock_cookie_t *); 1260Sstevel@tonic-gate extern void i_ndi_busop_fm_fini(dev_info_t *); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* fm cache support */ 1290Sstevel@tonic-gate void i_ndi_fmc_create(struct i_ddi_fmc **, int, ddi_iblock_cookie_t); 1300Sstevel@tonic-gate void i_ndi_fmc_destroy(struct i_ddi_fmc *); 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #endif /* _KERNEL */ 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate #ifdef __cplusplus 1350Sstevel@tonic-gate } 1360Sstevel@tonic-gate #endif 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate #endif /* _DDIFM_IMPL_H */ 139