xref: /titanic_44/usr/src/cmd/fm/fmd/common/fmd_event.h (revision bde3d612a7c090234c60e6e4578821237a5db135)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 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 	uint8_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 	uint8_t ev_ttl;			/* event time-to-live */
51 	nvlist_t *ev_nvl;		/* event name/value pair payload */
52 	void *ev_data;			/* event type-specific data pointer */
53 	fmd_timeval_t ev_time;		/* upper bound on event time-of-day */
54 	hrtime_t ev_hrt;		/* upper bound on event hrtime */
55 	struct fmd_log *ev_log;		/* event log (or NULL) */
56 	off64_t ev_off;			/* event log offset (or zero) */
57 	size_t ev_len;			/* event log record length (or zero) */
58 } fmd_event_impl_t;
59 
60 #define	FMD_EVT_PROTOCOL	0	/* protocol event (error/fault/list) */
61 #define	FMD_EVT_TIMEOUT		1	/* timeout expiry notification */
62 #define	FMD_EVT_CLOSE		2	/* case close request */
63 #define	FMD_EVT_STATS		3	/* statistics snapshot request */
64 #define	FMD_EVT_GC		4	/* garbage collection request */
65 #define	FMD_EVT_CTL		5	/* fmd control event (see fmd_ctl.c) */
66 #define	FMD_EVT_PUBLISH		6	/* case publish request */
67 #define	FMD_EVT_TOPO		7	/* topology change notification */
68 #define	FMD_EVT_NTYPES		8	/* 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