xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_event.h (revision 24db4641)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*24db4641Seschrock  * Common Development and Distribution License (the "License").
6*24db4641Seschrock  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*24db4641Seschrock  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate #ifndef	_FMD_EVENT_H
287c478bd9Sstevel@tonic-gate #define	_FMD_EVENT_H
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate #include <pthread.h>
337c478bd9Sstevel@tonic-gate #include <libnvpair.h>
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate #include <fmd_time.h>
407c478bd9Sstevel@tonic-gate #include <fmd_api.h>
427c478bd9Sstevel@tonic-gate struct fmd_log;				/* see <fmd_log.h> */
447c478bd9Sstevel@tonic-gate typedef struct fmd_event_impl {
457c478bd9Sstevel@tonic-gate 	pthread_mutex_t ev_lock;	/* lock protecting structure contents */
467c478bd9Sstevel@tonic-gate 	uint32_t ev_refs;		/* reference count */
47d9638e54Smws 	uint8_t ev_type;		/* event type (see below) */
487c478bd9Sstevel@tonic-gate 	uint8_t ev_state;		/* event state (see below) */
497c478bd9Sstevel@tonic-gate 	uint8_t ev_flags;		/* event flags (see below) */
50d9638e54Smws 	uint8_t ev_ttl;			/* event time-to-live */
517c478bd9Sstevel@tonic-gate 	nvlist_t *ev_nvl;		/* event name/value pair payload */
527c478bd9Sstevel@tonic-gate 	void *ev_data;			/* event type-specific data pointer */
537c478bd9Sstevel@tonic-gate 	fmd_timeval_t ev_time;		/* upper bound on event time-of-day */
547c478bd9Sstevel@tonic-gate 	hrtime_t ev_hrt;		/* upper bound on event hrtime */
557c478bd9Sstevel@tonic-gate 	struct fmd_log *ev_log;		/* event log (or NULL) */
567c478bd9Sstevel@tonic-gate 	off64_t ev_off;			/* event log offset (or zero) */
577c478bd9Sstevel@tonic-gate 	size_t ev_len;			/* event log record length (or zero) */
587c478bd9Sstevel@tonic-gate } fmd_event_impl_t;
607c478bd9Sstevel@tonic-gate #define	FMD_EVT_PROTOCOL	0	/* protocol event (error/fault/list) */
617c478bd9Sstevel@tonic-gate #define	FMD_EVT_TIMEOUT		1	/* timeout expiry notification */
627c478bd9Sstevel@tonic-gate #define	FMD_EVT_CLOSE		2	/* case close request */
637c478bd9Sstevel@tonic-gate #define	FMD_EVT_STATS		3	/* statistics snapshot request */
647c478bd9Sstevel@tonic-gate #define	FMD_EVT_GC		4	/* garbage collection request */
657c478bd9Sstevel@tonic-gate #define	FMD_EVT_CTL		5	/* fmd control event (see fmd_ctl.c) */
66d9638e54Smws #define	FMD_EVT_PUBLISH		6	/* case publish request */
67*24db4641Seschrock #define	FMD_EVT_TOPO		7	/* topology change notification */
68*24db4641Seschrock #define	FMD_EVT_NTYPES		8	/* number of event types */
707c478bd9Sstevel@tonic-gate #define	FMD_EVS_DISCARDED	0	/* discarded by all subscribers */
717c478bd9Sstevel@tonic-gate #define	FMD_EVS_RECEIVED	1	/* received but not yet processed */
727c478bd9Sstevel@tonic-gate #define	FMD_EVS_ACCEPTED	2	/* accepted and assigned to a case */
737c478bd9Sstevel@tonic-gate #define	FMD_EVS_DIAGNOSED	3	/* diagnosed and assigned to a case */
757c478bd9Sstevel@tonic-gate #define	FMD_EVF_VOLATILE	0x1	/* event is not yet written to a log */
767c478bd9Sstevel@tonic-gate #define	FMD_EVF_REPLAY		0x2	/* event is set for replay on restart */
77d9638e54Smws #define	FMD_EVF_LOCAL		0x4	/* event is from fmd or a local xprt */
797c478bd9Sstevel@tonic-gate #define	FMD_HRT_NOW		0	/* use current hrtime as event time */
81d9638e54Smws #define	FMD_EVENT_TYPE(e)	(((fmd_event_impl_t *)e)->ev_type)
82d9638e54Smws #define	FMD_EVENT_DATA(e)	(((fmd_event_impl_t *)e)->ev_data)
83d9638e54Smws #define	FMD_EVENT_NVL(e)	(((fmd_event_impl_t *)e)->ev_nvl)
84d9638e54Smws #define	FMD_EVENT_TTL(e)	(((fmd_event_impl_t *)e)->ev_ttl)
86d9638e54Smws #define	FMD_EVN_TOD	"__tod"		/* private name-value pair for ev_tod */
87d9638e54Smws #define	FMD_EVN_TTL	"__ttl"		/* private name-value pair for ev_ttl */
88d9638e54Smws #define	FMD_EVN_UUID	"__uuid"	/* private name-value pair for UUIDs */
907c478bd9Sstevel@tonic-gate extern fmd_event_t *fmd_event_recreate(uint_t, const fmd_timeval_t *,
917c478bd9Sstevel@tonic-gate     nvlist_t *, void *, struct fmd_log *, off64_t, size_t);
937c478bd9Sstevel@tonic-gate extern fmd_event_t *fmd_event_create(uint_t, hrtime_t, nvlist_t *, void *);
947c478bd9Sstevel@tonic-gate extern void fmd_event_destroy(fmd_event_t *);
957c478bd9Sstevel@tonic-gate extern void fmd_event_hold(fmd_event_t *);
967c478bd9Sstevel@tonic-gate extern void fmd_event_rele(fmd_event_t *);
987c478bd9Sstevel@tonic-gate extern void fmd_event_transition(fmd_event_t *, uint_t);
997c478bd9Sstevel@tonic-gate extern void fmd_event_commit(fmd_event_t *);
1017c478bd9Sstevel@tonic-gate extern hrtime_t fmd_event_delta(fmd_event_t *, fmd_event_t *);
1027c478bd9Sstevel@tonic-gate extern hrtime_t fmd_event_hrtime(fmd_event_t *);
104d9638e54Smws extern int fmd_event_match(fmd_event_t *, uint_t, const void *);
1057c478bd9Sstevel@tonic-gate extern int fmd_event_equal(fmd_event_t *, fmd_event_t *);
1077c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate #endif
1117c478bd9Sstevel@tonic-gate #endif	/* _FMD_EVENT_H */