17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 500d0963fSdilpreet * Common Development and Distribution License (the "License"). 600d0963fSdilpreet * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22eae2e508Skrishnae * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _DDIFM_IMPL_H 277c478bd9Sstevel@tonic-gate #define _DDIFM_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 307c478bd9Sstevel@tonic-gate #include <sys/errorq.h> 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate struct i_ddi_fmkstat { 377c478bd9Sstevel@tonic-gate kstat_named_t fek_erpt_dropped; /* total ereports dropped */ 38*a5667d81SCheng Sean Ye kstat_named_t fek_fmc_miss; /* total fmc misses */ 39*a5667d81SCheng Sean Ye kstat_named_t fek_fmc_full; /* total fmc allocs fail */ 407c478bd9Sstevel@tonic-gate kstat_named_t fek_acc_err; /* total access errors */ 417c478bd9Sstevel@tonic-gate kstat_named_t fek_dma_err; /* total dma errors */ 427c478bd9Sstevel@tonic-gate }; 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* Fault management error handler support */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #define DDI_MAX_ERPT_CLASS 64 477c478bd9Sstevel@tonic-gate #define DDI_FM_STKDEPTH 20 487c478bd9Sstevel@tonic-gate #define DDI_FM_SYM_SZ 64 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate struct i_ddi_errhdl { 517c478bd9Sstevel@tonic-gate int (*eh_func)(); /* error handler callback */ 527c478bd9Sstevel@tonic-gate void *eh_impl; /* callback arg */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* Fault management resource cache support */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate struct i_ddi_fmc_entry { 587c478bd9Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_prev; 597c478bd9Sstevel@tonic-gate struct i_ddi_fmc_entry *fce_next; 607c478bd9Sstevel@tonic-gate void *fce_resource; /* acc or DMA handle cached */ 617c478bd9Sstevel@tonic-gate void *fce_bus_specific; /* Bus-specific handle data */ 627c478bd9Sstevel@tonic-gate }; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate struct i_ddi_fmc { 65fa52d01bScindi kmutex_t fc_lock; /* cache active access */ 66*a5667d81SCheng Sean Ye struct i_ddi_fmc_entry *fc_head; /* active handle list */ 677c478bd9Sstevel@tonic-gate struct i_ddi_fmc_entry *fc_tail; /* tail of active handle list */ 687c478bd9Sstevel@tonic-gate }; 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* Error handler targets */ 717c478bd9Sstevel@tonic-gate struct i_ddi_fmtgt { 727c478bd9Sstevel@tonic-gate struct i_ddi_fmtgt *ft_next; /* next fm child target */ 737c478bd9Sstevel@tonic-gate dev_info_t *ft_dip; /* fm target error handler dip */ 747c478bd9Sstevel@tonic-gate struct i_ddi_errhdl *ft_errhdl; /* error handler */ 757c478bd9Sstevel@tonic-gate }; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate struct i_ddi_fmhdl { 787c478bd9Sstevel@tonic-gate kmutex_t fh_lock; /* error handler lock */ 79eae2e508Skrishnae kthread_t *fh_lock_owner; 807c478bd9Sstevel@tonic-gate struct i_ddi_fmc *fh_dma_cache; /* fm dma handle cache */ 817c478bd9Sstevel@tonic-gate struct i_ddi_fmc *fh_acc_cache; /* fm access handle cache */ 827c478bd9Sstevel@tonic-gate dev_info_t *fh_dip; 837c478bd9Sstevel@tonic-gate kstat_t *fh_ksp; /* pointer to installed kstat */ 847c478bd9Sstevel@tonic-gate int fh_cap; /* fm level for this instance */ 857c478bd9Sstevel@tonic-gate struct i_ddi_fmkstat fh_kstat; /* fm kstats for this inst */ 867c478bd9Sstevel@tonic-gate errorq_t *fh_errorq; /* errorq for this instance */ 877c478bd9Sstevel@tonic-gate nvlist_t *fh_fmri; /* optional fmri */ 887c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t fh_ibc; /* ibc for error handling */ 897c478bd9Sstevel@tonic-gate struct i_ddi_fmtgt *fh_tgts; /* registered fm tgts */ 907c478bd9Sstevel@tonic-gate void *fh_bus_specific; /* Bus specific FM info */ 917c478bd9Sstevel@tonic-gate }; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate typedef struct pci_fm_err { 947c478bd9Sstevel@tonic-gate char *err_class; 9500d0963fSdilpreet uint32_t reg_bit; 967c478bd9Sstevel@tonic-gate char *terr_class; 9700d0963fSdilpreet int flags; 987c478bd9Sstevel@tonic-gate } pci_fm_err_t; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern pci_fm_err_t pci_err_tbl[]; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate #ifdef _KERNEL 10300d0963fSdilpreet typedef int (*ddi_fmcompare_t)(dev_info_t *, const void *, const void *, 10400d0963fSdilpreet const void *); 1057c478bd9Sstevel@tonic-gate 106*a5667d81SCheng Sean Ye extern void ndi_fm_init(void); 107*a5667d81SCheng Sean Ye 1087c478bd9Sstevel@tonic-gate /* driver defect error reporting */ 109*a5667d81SCheng Sean Ye extern void i_ddi_drv_ereport_post(dev_info_t *, const char *, nvlist_t *, int); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* target error handler add/remove/dispatch */ 1127c478bd9Sstevel@tonic-gate extern void i_ddi_fm_handler_enter(dev_info_t *); 1137c478bd9Sstevel@tonic-gate extern void i_ddi_fm_handler_exit(dev_info_t *); 114eae2e508Skrishnae extern boolean_t i_ddi_fm_handler_owned(dev_info_t *); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* access and dma handle protection support */ 1177c478bd9Sstevel@tonic-gate extern void i_ddi_fm_acc_err_set(ddi_acc_handle_t, uint64_t, int, int); 1187c478bd9Sstevel@tonic-gate extern void i_ddi_fm_dma_err_set(ddi_dma_handle_t, uint64_t, int, int); 11900d0963fSdilpreet extern ddi_fmcompare_t i_ddi_fm_acc_err_cf_get(ddi_acc_handle_t); 12000d0963fSdilpreet extern ddi_fmcompare_t i_ddi_fm_dma_err_cf_get(ddi_dma_handle_t); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* fm busop support */ 1237c478bd9Sstevel@tonic-gate extern void i_ndi_busop_access_enter(dev_info_t *, ddi_acc_handle_t); 1247c478bd9Sstevel@tonic-gate extern void i_ndi_busop_access_exit(dev_info_t *, ddi_acc_handle_t); 1257c478bd9Sstevel@tonic-gate extern int i_ndi_busop_fm_init(dev_info_t *, int, ddi_iblock_cookie_t *); 1267c478bd9Sstevel@tonic-gate extern void i_ndi_busop_fm_fini(dev_info_t *); 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* fm cache support */ 1297c478bd9Sstevel@tonic-gate void i_ndi_fmc_create(struct i_ddi_fmc **, int, ddi_iblock_cookie_t); 1307c478bd9Sstevel@tonic-gate void i_ndi_fmc_destroy(struct i_ddi_fmc *); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1357c478bd9Sstevel@tonic-gate } 1367c478bd9Sstevel@tonic-gate #endif 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #endif /* _DDIFM_IMPL_H */ 139