1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _DDIFM_IMPL_H 28 #define _DDIFM_IMPL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/dditypes.h> 33 #include <sys/errorq.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 struct i_ddi_fmkstat { 40 kstat_named_t fek_erpt_dropped; /* total ereports dropped */ 41 kstat_named_t fek_fmc_full; /* total fmc insert fails */ 42 kstat_named_t fek_fmc_grew; /* total fmc grew succeed */ 43 kstat_named_t fek_acc_err; /* total access errors */ 44 kstat_named_t fek_dma_err; /* total dma errors */ 45 }; 46 47 /* Fault management error handler support */ 48 49 #define DDI_MAX_ERPT_CLASS 64 50 #define DDI_FM_STKDEPTH 20 51 #define DDI_FM_SYM_SZ 64 52 53 struct i_ddi_errhdl { 54 int (*eh_func)(); /* error handler callback */ 55 void *eh_impl; /* callback arg */ 56 }; 57 58 /* Fault management resource cache support */ 59 60 struct i_ddi_fmc_entry { 61 struct i_ddi_fmc_entry *fce_prev; 62 struct i_ddi_fmc_entry *fce_next; 63 void *fce_resource; /* acc or DMA handle cached */ 64 void *fce_bus_specific; /* Bus-specific handle data */ 65 }; 66 67 struct i_ddi_fmc { 68 kmutex_t fc_lock; /* exclusive cache access */ 69 int fc_len; /* length of FM cache array */ 70 struct i_ddi_fmc_entry *fc_elems; /* FM cache array */ 71 struct i_ddi_fmc_entry *fc_free; /* free list */ 72 struct i_ddi_fmc_entry *fc_tail; /* tail of active handle list */ 73 struct i_ddi_fmc_entry *fc_active; /* active handle list */ 74 }; 75 76 /* Error handler targets */ 77 struct i_ddi_fmtgt { 78 struct i_ddi_fmtgt *ft_next; /* next fm child target */ 79 dev_info_t *ft_dip; /* fm target error handler dip */ 80 struct i_ddi_errhdl *ft_errhdl; /* error handler */ 81 }; 82 83 struct i_ddi_fmhdl { 84 kmutex_t fh_lock; /* error handler lock */ 85 struct i_ddi_fmc *fh_dma_cache; /* fm dma handle cache */ 86 struct i_ddi_fmc *fh_acc_cache; /* fm access handle cache */ 87 dev_info_t *fh_dip; 88 kstat_t *fh_ksp; /* pointer to installed kstat */ 89 int fh_cap; /* fm level for this instance */ 90 struct i_ddi_fmkstat fh_kstat; /* fm kstats for this inst */ 91 errorq_t *fh_errorq; /* errorq for this instance */ 92 nvlist_t *fh_fmri; /* optional fmri */ 93 ddi_iblock_cookie_t fh_ibc; /* ibc for error handling */ 94 struct i_ddi_fmtgt *fh_tgts; /* registered fm tgts */ 95 void *fh_bus_specific; /* Bus specific FM info */ 96 }; 97 98 typedef struct pci_fm_err { 99 char *err_class; 100 uint16_t reg_bit; 101 char *terr_class; 102 } pci_fm_err_t; 103 104 extern pci_fm_err_t pci_err_tbl[]; 105 106 #ifdef _KERNEL 107 108 /* driver defect error reporting */ 109 void i_ddi_drv_ereport_post(dev_info_t *, const char *, nvlist_t *, int); 110 111 /* target error handler add/remove/dispatch */ 112 extern void i_ddi_fm_handler_enter(dev_info_t *); 113 extern void i_ddi_fm_handler_exit(dev_info_t *); 114 115 /* access and dma handle protection support */ 116 extern void i_ddi_fm_acc_err_set(ddi_acc_handle_t, uint64_t, int, int); 117 extern void i_ddi_fm_dma_err_set(ddi_dma_handle_t, uint64_t, int, int); 118 119 /* fm busop support */ 120 extern void i_ndi_busop_access_enter(dev_info_t *, ddi_acc_handle_t); 121 extern void i_ndi_busop_access_exit(dev_info_t *, ddi_acc_handle_t); 122 extern int i_ndi_busop_fm_init(dev_info_t *, int, ddi_iblock_cookie_t *); 123 extern void i_ndi_busop_fm_fini(dev_info_t *); 124 125 /* fm cache support */ 126 void i_ndi_fmc_create(struct i_ddi_fmc **, int, ddi_iblock_cookie_t); 127 void i_ndi_fmc_destroy(struct i_ddi_fmc *); 128 129 #endif /* _KERNEL */ 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* _DDIFM_IMPL_H */ 136