summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/ddifm.h
blob: ef2dc453c89ec40369b22447399f15a3d7e1aa6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_DDIFM_H
#define	_DDIFM_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/dditypes.h>
#include <sys/va_list.h>

extern int ddi_system_fmcap;

/* Fault Management error handling */

/* Error handling return status */
#define	DDI_FM_OK		0
#define	DDI_FM_FATAL	-1
#define	DDI_FM_NONFATAL	-2
#define	DDI_FM_UNKNOWN	-3

/* Driver fault management capabilities */
#define	DDI_FM_NOT_CAPABLE	0x00000000
#define	DDI_FM_EREPORT_CAPABLE	0x00000001
#define	DDI_FM_ACCCHK_CAPABLE	0x00000002
#define	DDI_FM_DMACHK_CAPABLE	0x00000004
#define	DDI_FM_ERRCB_CAPABLE	0x00000008

#define	DDI_FM_DEFAULT_CAP(cap)	(cap == DDI_FM_NOT_CAPABLE)
#define	DDI_FM_EREPORT_CAP(cap)	(cap & DDI_FM_EREPORT_CAPABLE)
#define	DDI_FM_ACC_ERR_CAP(cap)	(cap & DDI_FM_ACCCHK_CAPABLE)
#define	DDI_FM_DMA_ERR_CAP(cap)	(cap & DDI_FM_DMACHK_CAPABLE)
#define	DDI_FM_ERRCB_CAP(cap)	(cap & DDI_FM_ERRCB_CAPABLE)

/* error expectation values */
#define	DDI_FM_ERR_UNEXPECTED	0
#define	DDI_FM_ERR_EXPECTED	1
#define	DDI_FM_ERR_POKE		2
#define	DDI_FM_ERR_PEEK		3

#ifdef _KERNEL

typedef struct ddi_fm_error {
	int fme_version;			/* version of this structure */
	int fme_status;				/* status for this error */
	int fme_flag;				/* error expectation flag */
	uint64_t fme_ena;			/* ENA for this error */
	ddi_acc_handle_t fme_acc_handle;	/* optional acc handle */
	ddi_dma_handle_t fme_dma_handle;	/* optional dma handle */
	void *fme_bus_specific;			/* optional bus specific err */
	int fme_bus_type;			/* optional bus type */
} ddi_fm_error_t;

#define	DDI_FME_VER0	0
#define	DDI_FME_VER1	1
#define	DDI_FME_VERSION	DDI_FME_VER1

#define	DDI_FME_BUS_TYPE_DFLT	0		/* bus type = default */
#define	DDI_FME_BUS_TYPE_PCI	1		/* bus type = pci/pcix/pcie */

typedef int (*ddi_err_func_t)(dev_info_t *, ddi_fm_error_t *, const void *);

/*
 * DDI for error handling and ereport generation
 */

/*
 * ereport generation: [ddi|ndi]_fm_ereport_post
 */
extern void ddi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...);
extern void ndi_fm_ereport_post(dev_info_t *, const char *, uint64_t, int, ...);

/*
 * service changes:
 *
 * After a hardened driver raises an ereport (or after pci_ereport_post() has
 * raised an ereport for an event which implecated one of a driver's access or
 * dma handles), the driver should always determine the service impact and
 * report it.
 */
extern void ddi_fm_service_impact(dev_info_t *, int);

/* error handling */
extern void ddi_fm_handler_register(dev_info_t *, ddi_err_func_t, void *);
extern void ddi_fm_handler_unregister(dev_info_t *);

/* fault management initialization and clean-up */
extern void ddi_fm_init(dev_info_t *, int *, ddi_iblock_cookie_t *);
extern void ddi_fm_fini(dev_info_t *);
extern int ddi_fm_capable(dev_info_t *dip);

/* access and dma handle error protection */
extern void ddi_fm_dma_err_get(ddi_dma_handle_t, ddi_fm_error_t *, int);
extern void ddi_fm_acc_err_get(ddi_acc_handle_t, ddi_fm_error_t *, int);
extern void ddi_fm_dma_err_clear(ddi_dma_handle_t, int);
extern void ddi_fm_acc_err_clear(ddi_acc_handle_t, int);

#endif /* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _DDIFM_H */