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 /* 2200d0963fSdilpreet * Copyright 2006 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> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate extern int ddi_system_fmcap; 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* Fault Management error handling */ 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* Error handling return status */ 427c478bd9Sstevel@tonic-gate #define DDI_FM_OK 0 437c478bd9Sstevel@tonic-gate #define DDI_FM_FATAL -1 447c478bd9Sstevel@tonic-gate #define DDI_FM_NONFATAL -2 457c478bd9Sstevel@tonic-gate #define DDI_FM_UNKNOWN -3 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* Driver fault management capabilities */ 487c478bd9Sstevel@tonic-gate #define DDI_FM_NOT_CAPABLE 0x00000000 497c478bd9Sstevel@tonic-gate #define DDI_FM_EREPORT_CAPABLE 0x00000001 507c478bd9Sstevel@tonic-gate #define DDI_FM_ACCCHK_CAPABLE 0x00000002 517c478bd9Sstevel@tonic-gate #define DDI_FM_DMACHK_CAPABLE 0x00000004 527c478bd9Sstevel@tonic-gate #define DDI_FM_ERRCB_CAPABLE 0x00000008 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #define DDI_FM_DEFAULT_CAP(cap) (cap == DDI_FM_NOT_CAPABLE) 557c478bd9Sstevel@tonic-gate #define DDI_FM_EREPORT_CAP(cap) (cap & DDI_FM_EREPORT_CAPABLE) 567c478bd9Sstevel@tonic-gate #define DDI_FM_ACC_ERR_CAP(cap) (cap & DDI_FM_ACCCHK_CAPABLE) 577c478bd9Sstevel@tonic-gate #define DDI_FM_DMA_ERR_CAP(cap) (cap & DDI_FM_DMACHK_CAPABLE) 587c478bd9Sstevel@tonic-gate #define DDI_FM_ERRCB_CAP(cap) (cap & DDI_FM_ERRCB_CAPABLE) 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* error expectation values */ 617c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_UNEXPECTED 0 627c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_EXPECTED 1 637c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_POKE 2 647c478bd9Sstevel@tonic-gate #define DDI_FM_ERR_PEEK 3 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #ifdef _KERNEL 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate typedef struct ddi_fm_error { 697c478bd9Sstevel@tonic-gate int fme_version; /* version of this structure */ 707c478bd9Sstevel@tonic-gate int fme_status; /* status for this error */ 717c478bd9Sstevel@tonic-gate int fme_flag; /* error expectation flag */ 727c478bd9Sstevel@tonic-gate uint64_t fme_ena; /* ENA for this error */ 737c478bd9Sstevel@tonic-gate ddi_acc_handle_t fme_acc_handle; /* optional acc handle */ 747c478bd9Sstevel@tonic-gate ddi_dma_handle_t fme_dma_handle; /* optional dma handle */ 757c478bd9Sstevel@tonic-gate void *fme_bus_specific; /* optional bus specific err */ 76*8aec9182Sstephh int fme_bus_type; /* optional bus type */ 777c478bd9Sstevel@tonic-gate } ddi_fm_error_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #define DDI_FME_VER0 0 80*8aec9182Sstephh #define DDI_FME_VER1 1 81*8aec9182Sstephh #define DDI_FME_VERSION DDI_FME_VER1 82*8aec9182Sstephh 83*8aec9182Sstephh #define DDI_FME_BUS_TYPE_DFLT 0 /* bus type = default */ 84*8aec9182Sstephh #define DDI_FME_BUS_TYPE_PCI 1 /* bus type = pci/pcix/pcie */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate typedef int (*ddi_err_func_t)(dev_info_t *, ddi_fm_error_t *, const void *); 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * DDI for error handling and ereport generation 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* ereporting and service changes */ 937c478bd9Sstevel@tonic-gate extern void ddi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...); 9400d0963fSdilpreet 9500d0963fSdilpreet /* 9600d0963fSdilpreet * After a hardened driver raises an ereport (or after pci_ereport_post() has 9700d0963fSdilpreet * raised an ereport for an event which implecated one of a driver's access or 9800d0963fSdilpreet * dma handles), the driver should always determine the service impact and 9900d0963fSdilpreet * report it. 10000d0963fSdilpreet */ 1017c478bd9Sstevel@tonic-gate extern void ddi_fm_service_impact(dev_info_t *, int); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* error handling */ 1047c478bd9Sstevel@tonic-gate extern void ddi_fm_handler_register(dev_info_t *, ddi_err_func_t, void *); 1057c478bd9Sstevel@tonic-gate extern void ddi_fm_handler_unregister(dev_info_t *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* fault management initialization and clean-up */ 1087c478bd9Sstevel@tonic-gate extern void ddi_fm_init(dev_info_t *, int *, ddi_iblock_cookie_t *); 1097c478bd9Sstevel@tonic-gate extern void ddi_fm_fini(dev_info_t *); 1107c478bd9Sstevel@tonic-gate extern int ddi_fm_capable(dev_info_t *dip); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* access and dma handle error protection */ 1137c478bd9Sstevel@tonic-gate extern void ddi_fm_dma_err_get(ddi_dma_handle_t, ddi_fm_error_t *, int); 1147c478bd9Sstevel@tonic-gate extern void ddi_fm_acc_err_get(ddi_acc_handle_t, ddi_fm_error_t *, int); 11500d0963fSdilpreet extern void ddi_fm_dma_err_clear(ddi_dma_handle_t, int); 11600d0963fSdilpreet extern void ddi_fm_acc_err_clear(ddi_acc_handle_t, int); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate #endif 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #endif /* _DDIFM_H */ 125