xref: /titanic_52/usr/src/uts/common/sys/errorq_impl.h (revision c2580b931007758eab8cb5ae8726ebe1588e259b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_ERRORQ_IMPL_H
28 #define	_ERRORQ_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/errorq.h>
33 #include <sys/dditypes.h>
34 #include <sys/kstat.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 typedef struct errorq_nvelem {
41 	void *eqn_buf;			/* data buf for this nv element */
42 	nvlist_t *eqn_nvl;		/* nvlist */
43 	nv_alloc_t *eqn_nva;		/* fixed nv allocator */
44 } errorq_nvelem_t;
45 
46 struct errorq_elem {
47 	struct errorq_elem *eqe_next;		/* next on processing list */
48 	struct errorq_elem *eqe_prev;		/* prev on free or pend list */
49 	struct errorq_elem *eqe_dump;		/* next on crash dump list */
50 	void *eqe_data;				/* data for this element */
51 };
52 
53 typedef struct errorq_kstat {
54 	kstat_named_t eqk_dispatched;		/* total errors dispatched */
55 	kstat_named_t eqk_dropped;		/* total errors dropped */
56 	kstat_named_t eqk_logged;		/* total errors logged */
57 	kstat_named_t eqk_reserved;		/* total errors reserved */
58 	kstat_named_t eqk_reserve_fail;		/* total reservation failures */
59 	kstat_named_t eqk_committed;		/* total errors committed */
60 	kstat_named_t eqk_commit_fail;		/* total commit failures */
61 	kstat_named_t eqk_cancelled;		/* total reserves cancelled */
62 } errorq_kstat_t;
63 
64 /*
65  * errorq implementation flags: bit range 16-31
66  */
67 #define	ERRORQ_ACTIVE	0x00010000		/* queue is enabled */
68 #define	ERRORQ_NVLIST	0x00020000		/* nvlist queue */
69 
70 #define	ERRORQ_NAMELEN	31			/* length of queue name */
71 
72 struct errorq {
73 	char eq_name[ERRORQ_NAMELEN + 1];	/* string name for debugging */
74 	errorq_kstat_t eq_kstat;		/* kstat data (see above) */
75 	kstat_t *eq_ksp;			/* pointer to installed kstat */
76 	errorq_func_t eq_func;			/* drain callback */
77 	void *eq_private;			/* drain callback data */
78 	void *eq_data;				/* buffer of queue data */
79 	ulong_t eq_qlen;			/* maximum queue length */
80 	size_t eq_size;				/* size of element data */
81 	uint_t eq_ipl;				/* soft interrupt priority */
82 	uint_t eq_flags;			/* flags (see above) */
83 	ddi_softintr_t eq_id;			/* soft interrupt identifier */
84 	kmutex_t eq_lock;			/* consumer lock */
85 	errorq_elem_t *eq_elems;		/* array of all elements */
86 	errorq_elem_t *eq_phead;		/* head of processing list */
87 	errorq_elem_t *eq_ptail;		/* tail of processing list */
88 	errorq_elem_t *eq_pend;			/* list of pending errors */
89 	errorq_elem_t *eq_free;			/* list of free elements */
90 	errorq_elem_t *eq_dump;			/* list of crash dump elem's */
91 	struct errorq *eq_next;			/* next errorq on global list */
92 };
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif	/* _ERRORQ_IMPL_H */
99