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 /* 221865Sdilpreet * 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 _DDIFM_IMPL_H 270Sstevel@tonic-gate #define _DDIFM_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/dditypes.h> 320Sstevel@tonic-gate #include <sys/errorq.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate struct i_ddi_fmkstat { 390Sstevel@tonic-gate kstat_named_t fek_erpt_dropped; /* total ereports dropped */ 400Sstevel@tonic-gate kstat_named_t fek_fmc_full; /* total fmc insert fails */ 410Sstevel@tonic-gate kstat_named_t fek_fmc_grew; /* total fmc grew succeed */ 420Sstevel@tonic-gate kstat_named_t fek_acc_err; /* total access errors */ 430Sstevel@tonic-gate kstat_named_t fek_dma_err; /* total dma errors */ 440Sstevel@tonic-gate }; 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* Fault management error handler support */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate #define DDI_MAX_ERPT_CLASS 64 490Sstevel@tonic-gate #define DDI_FM_STKDEPTH 20 500Sstevel@tonic-gate #define DDI_FM_SYM_SZ 64 510Sstevel@tonic-gate 520Sstevel@tonic-gate struct i_ddi_errhdl { 530Sstevel@tonic-gate int (*eh_func)(); /* error handler callback */ 540Sstevel@tonic-gate void *eh_impl; /* callback arg */ 550Sstevel@tonic-gate }; 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* Fault management resource cache support */ 580Sstevel@tonic-gate 590Sstevel@tonic-gate struct i_ddi_fmc_entry { 600Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_prev; 610Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_next; 620Sstevel@tonic-gate void *fce_resource; /* acc or DMA handle cached */ 630Sstevel@tonic-gate void *fce_bus_specific; /* Bus-specific handle data */ 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 660Sstevel@tonic-gate struct i_ddi_fmc { 67*3114Scindi kmutex_t fc_lock; /* cache active access */ 68*3114Scindi kmutex_t fc_free_lock; /* cache freelist access */ 690Sstevel@tonic-gate int fc_len; /* length of FM cache array */ 700Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_elems; /* FM cache array */ 710Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_free; /* free list */ 720Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_tail; /* tail of active handle list */ 730Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_active; /* active handle list */ 740Sstevel@tonic-gate }; 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* Error handler targets */ 770Sstevel@tonic-gate struct i_ddi_fmtgt { 780Sstevel@tonic-gate struct i_ddi_fmtgt *ft_next; /* next fm child target */ 790Sstevel@tonic-gate dev_info_t *ft_dip; /* fm target error handler dip */ 800Sstevel@tonic-gate struct i_ddi_errhdl *ft_errhdl; /* error handler */ 810Sstevel@tonic-gate }; 820Sstevel@tonic-gate 830Sstevel@tonic-gate struct i_ddi_fmhdl { 840Sstevel@tonic-gate kmutex_t fh_lock; /* error handler lock */ 850Sstevel@tonic-gate struct i_ddi_fmc *fh_dma_cache; /* fm dma handle cache */ 860Sstevel@tonic-gate struct i_ddi_fmc *fh_acc_cache; /* fm access handle cache */ 870Sstevel@tonic-gate dev_info_t *fh_dip; 880Sstevel@tonic-gate kstat_t *fh_ksp; /* pointer to installed kstat */ 890Sstevel@tonic-gate int fh_cap; /* fm level for this instance */ 900Sstevel@tonic-gate struct i_ddi_fmkstat fh_kstat; /* fm kstats for this inst */ 910Sstevel@tonic-gate errorq_t *fh_errorq; /* errorq for this instance */ 920Sstevel@tonic-gate nvlist_t *fh_fmri; /* optional fmri */ 930Sstevel@tonic-gate ddi_iblock_cookie_t fh_ibc; /* ibc for error handling */ 940Sstevel@tonic-gate struct i_ddi_fmtgt *fh_tgts; /* registered fm tgts */ 950Sstevel@tonic-gate void *fh_bus_specific; /* Bus specific FM info */ 960Sstevel@tonic-gate }; 970Sstevel@tonic-gate 980Sstevel@tonic-gate typedef struct pci_fm_err { 990Sstevel@tonic-gate char *err_class; 1001865Sdilpreet uint32_t reg_bit; 1010Sstevel@tonic-gate char *terr_class; 1021865Sdilpreet int flags; 1030Sstevel@tonic-gate } pci_fm_err_t; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate extern pci_fm_err_t pci_err_tbl[]; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #ifdef _KERNEL 1081865Sdilpreet typedef int (*ddi_fmcompare_t)(dev_info_t *, const void *, const void *, 1091865Sdilpreet const void *); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* driver defect error reporting */ 1120Sstevel@tonic-gate void i_ddi_drv_ereport_post(dev_info_t *, const char *, nvlist_t *, int); 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* target error handler add/remove/dispatch */ 1150Sstevel@tonic-gate extern void i_ddi_fm_handler_enter(dev_info_t *); 1160Sstevel@tonic-gate extern void i_ddi_fm_handler_exit(dev_info_t *); 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* access and dma handle protection support */ 1190Sstevel@tonic-gate extern void i_ddi_fm_acc_err_set(ddi_acc_handle_t, uint64_t, int, int); 1200Sstevel@tonic-gate extern void i_ddi_fm_dma_err_set(ddi_dma_handle_t, uint64_t, int, int); 1211865Sdilpreet extern ddi_fmcompare_t i_ddi_fm_acc_err_cf_get(ddi_acc_handle_t); 1221865Sdilpreet extern ddi_fmcompare_t i_ddi_fm_dma_err_cf_get(ddi_dma_handle_t); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* fm busop support */ 1250Sstevel@tonic-gate extern void i_ndi_busop_access_enter(dev_info_t *, ddi_acc_handle_t); 1260Sstevel@tonic-gate extern void i_ndi_busop_access_exit(dev_info_t *, ddi_acc_handle_t); 1270Sstevel@tonic-gate extern int i_ndi_busop_fm_init(dev_info_t *, int, ddi_iblock_cookie_t *); 1280Sstevel@tonic-gate extern void i_ndi_busop_fm_fini(dev_info_t *); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* fm cache support */ 1310Sstevel@tonic-gate void i_ndi_fmc_create(struct i_ddi_fmc **, int, ddi_iblock_cookie_t); 1320Sstevel@tonic-gate void i_ndi_fmc_destroy(struct i_ddi_fmc *); 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate #endif /* _KERNEL */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #ifdef __cplusplus 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate #endif 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate #endif /* _DDIFM_IMPL_H */ 141