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