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 /* 22*602ca9eaScth * 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_H 277c478bd9Sstevel@tonic-gate #define _DDIFM_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 34*602ca9eaScth #include <sys/va_list.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate extern int ddi_system_fmcap; 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* Fault Management error handling */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* Error handling return status */ 417c478bd9Sstevel@tonic-gate #define DDI_FM_OK 0 427c478bd9Sstevel@tonic-gate #define DDI_FM_FATAL -1 437c478bd9Sstevel@tonic-gate #define DDI_FM_NONFATAL -2 447c478bd9Sstevel@tonic-gate #define DDI_FM_UNKNOWN -3 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* Driver fault management capabilities */ 477c478bd9Sstevel@tonic-gate #define DDI_FM_NOT_CAPABLE 0x00000000 487c478bd9Sstevel@tonic-gate #define DDI_FM_EREPORT_CAPABLE 0x00000001 497c478bd9Sstevel@tonic-gate #define DDI_FM_ACCCHK_CAPABLE 0x00000002 507c478bd9Sstevel@tonic-gate #define DDI_FM_DMACHK_CAPABLE 0x00000004 517c478bd9Sstevel@tonic-gate #define DDI_FM_ERRCB_CAPABLE 0x00000008 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define DDI_FM_DEFAULT_CAP(cap) (cap == DDI_FM_NOT_CAPABLE) 547c478bd9Sstevel@tonic-gate #define DDI_FM_EREPORT_CAP(cap) (cap & DDI_FM_EREPORT_CAPABLE) 557c478bd9Sstevel@tonic-gate #define DDI_FM_ACC_ERR_CAP(cap) (cap & DDI_FM_ACCCHK_CAPABLE) 567c478bd9Sstevel@tonic-gate #define DDI_FM_DMA_ERR_CAP(cap) (cap & DDI_FM_DMACHK_CAPABLE) 577c478bd9Sstevel@tonic-gate #define DDI_FM_ERRCB_CAP(cap) (cap & DDI_FM_ERRCB_CAPABLE) 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* error expectation values */ 607c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_UNEXPECTED 0 617c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_EXPECTED 1 627c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_POKE 2 637c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_PEEK 3 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #ifdef _KERNEL 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate typedef struct ddi_fm_error { 687c478bd9Sstevel@tonic-gate int fme_version; /* version of this structure */ 697c478bd9Sstevel@tonic-gate int fme_status; /* status for this error */ 707c478bd9Sstevel@tonic-gate int fme_flag; /* error expectation flag */ 717c478bd9Sstevel@tonic-gate uint64_t fme_ena; /* ENA for this error */ 727c478bd9Sstevel@tonic-gate ddi_acc_handle_t fme_acc_handle; /* optional acc handle */ 737c478bd9Sstevel@tonic-gate ddi_dma_handle_t fme_dma_handle; /* optional dma handle */ 747c478bd9Sstevel@tonic-gate void *fme_bus_specific; /* optional bus specific err */ 758aec9182Sstephh int fme_bus_type; /* optional bus type */ 767c478bd9Sstevel@tonic-gate } ddi_fm_error_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #define DDI_FME_VER0 0 798aec9182Sstephh #define DDI_FME_VER1 1 808aec9182Sstephh #define DDI_FME_VERSION DDI_FME_VER1 818aec9182Sstephh 828aec9182Sstephh #define DDI_FME_BUS_TYPE_DFLT 0 /* bus type = default */ 838aec9182Sstephh #define DDI_FME_BUS_TYPE_PCI 1 /* bus type = pci/pcix/pcie */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate typedef int (*ddi_err_func_t)(dev_info_t *, ddi_fm_error_t *, const void *); 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * DDI for error handling and ereport generation 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate 91*602ca9eaScth /* 92*602ca9eaScth * ereport generation: [ddi|ndi]_fm_ereport_post 93*602ca9eaScth */ 947c478bd9Sstevel@tonic-gate extern void ddi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...); 95*602ca9eaScth extern void ndi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...); 9600d0963fSdilpreet 9700d0963fSdilpreet /* 98*602ca9eaScth * service changes: 99*602ca9eaScth * 10000d0963fSdilpreet * After a hardened driver raises an ereport (or after pci_ereport_post() has 10100d0963fSdilpreet * raised an ereport for an event which implecated one of a driver's access or 10200d0963fSdilpreet * dma handles), the driver should always determine the service impact and 10300d0963fSdilpreet * report it. 10400d0963fSdilpreet */ 1057c478bd9Sstevel@tonic-gate extern void ddi_fm_service_impact(dev_info_t *, int); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* error handling */ 1087c478bd9Sstevel@tonic-gate extern void ddi_fm_handler_register(dev_info_t *, ddi_err_func_t, void *); 1097c478bd9Sstevel@tonic-gate extern void ddi_fm_handler_unregister(dev_info_t *); 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* fault management initialization and clean-up */ 1127c478bd9Sstevel@tonic-gate extern void ddi_fm_init(dev_info_t *, int *, ddi_iblock_cookie_t *); 1137c478bd9Sstevel@tonic-gate extern void ddi_fm_fini(dev_info_t *); 1147c478bd9Sstevel@tonic-gate extern int ddi_fm_capable(dev_info_t *dip); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* access and dma handle error protection */ 1177c478bd9Sstevel@tonic-gate extern void ddi_fm_dma_err_get(ddi_dma_handle_t, ddi_fm_error_t *, int); 1187c478bd9Sstevel@tonic-gate extern void ddi_fm_acc_err_get(ddi_acc_handle_t, ddi_fm_error_t *, int); 11900d0963fSdilpreet extern void ddi_fm_dma_err_clear(ddi_dma_handle_t, int); 12000d0963fSdilpreet extern void ddi_fm_acc_err_clear(ddi_acc_handle_t, int); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate #endif 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #endif /* _DDIFM_H */ 129