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