xref: /titanic_51/usr/src/cmd/fm/fmd/common/fmd_event.h (revision c69906bdd99a073749de104d2fa9cd6bf889f3c5)
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	_FMD_EVENT_H
28 #define	_FMD_EVENT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <pthread.h>
33 #include <libnvpair.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #include <fmd_time.h>
40 #include <fmd_api.h>
41 
42 struct fmd_log;				/* see <fmd_log.h> */
43 
44 typedef struct fmd_event_impl {
45 	pthread_mutex_t ev_lock;	/* lock protecting structure contents */
46 	uint32_t ev_refs;		/* reference count */
47 	uint16_t ev_type;		/* event type (see below) */
48 	uint8_t ev_state;		/* event state (see below) */
49 	uint8_t ev_flags;		/* event flags (see below) */
50 	nvlist_t *ev_nvl;		/* event name/value pair payload */
51 	void *ev_data;			/* event type-specific data pointer */
52 	fmd_timeval_t ev_time;		/* upper bound on event time-of-day */
53 	hrtime_t ev_hrt;		/* upper bound on event hrtime */
54 	struct fmd_log *ev_log;		/* event log (or NULL) */
55 	off64_t ev_off;			/* event log offset (or zero) */
56 	size_t ev_len;			/* event log record length (or zero) */
57 } fmd_event_impl_t;
58 
59 #define	FMD_EVT_PROTOCOL	0	/* protocol event (error/fault/list) */
60 #define	FMD_EVT_TIMEOUT		1	/* timeout expiry notification */
61 #define	FMD_EVT_CLOSE		2	/* case close request */
62 #define	FMD_EVT_STATS		3	/* statistics snapshot request */
63 #define	FMD_EVT_GC		4	/* garbage collection request */
64 #define	FMD_EVT_CTL		5	/* fmd control event (see fmd_ctl.c) */
65 #define	FMD_EVT_NTYPES		6	/* number of event types */
66 
67 #define	FMD_EVS_DISCARDED	0	/* discarded by all subscribers */
68 #define	FMD_EVS_RECEIVED	1	/* received but not yet processed */
69 #define	FMD_EVS_ACCEPTED	2	/* accepted and assigned to a case */
70 #define	FMD_EVS_DIAGNOSED	3	/* diagnosed and assigned to a case */
71 
72 #define	FMD_EVF_VOLATILE	0x1	/* event is not yet written to a log */
73 #define	FMD_EVF_REPLAY		0x2	/* event is set for replay on restart */
74 
75 #define	FMD_HRT_NOW		0	/* use current hrtime as event time */
76 
77 extern fmd_event_t *fmd_event_recreate(uint_t, const fmd_timeval_t *,
78     nvlist_t *, void *, struct fmd_log *, off64_t, size_t);
79 
80 extern fmd_event_t *fmd_event_create(uint_t, hrtime_t, nvlist_t *, void *);
81 extern void fmd_event_destroy(fmd_event_t *);
82 extern void fmd_event_hold(fmd_event_t *);
83 extern void fmd_event_rele(fmd_event_t *);
84 
85 extern void fmd_event_transition(fmd_event_t *, uint_t);
86 extern void fmd_event_commit(fmd_event_t *);
87 
88 extern hrtime_t fmd_event_delta(fmd_event_t *, fmd_event_t *);
89 extern hrtime_t fmd_event_hrtime(fmd_event_t *);
90 
91 extern int fmd_event_match(fmd_event_t *, uint_t, void *);
92 extern int fmd_event_equal(fmd_event_t *, fmd_event_t *);
93 
94 #ifdef	__cplusplus
95 }
96 #endif
97 
98 #endif	/* _FMD_EVENT_H */
99