xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_serd.h (revision 90f7985f020eb82d06bd0d75396ff794105f7528)
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_SERD_H
28 #define	_FMD_SERD_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <fmd_event.h>
35 #include <fmd_list.h>
36 
37 typedef struct fmd_serd_elem {
38 	fmd_list_t se_list;		/* linked list forward/back pointers */
39 	fmd_event_t *se_event;		/* pointer to corresponding event */
40 } fmd_serd_elem_t;
41 
42 typedef struct fmd_serd_eng {
43 	char *sg_name;			/* string name for this engine */
44 	struct fmd_serd_eng *sg_next;	/* next engine on hash chain */
45 	fmd_list_t sg_list;		/* list of fmd_serd_elem_t's */
46 	uint_t sg_count;		/* count of events in sg_list */
47 	uint_t sg_flags;		/* engine flags (see below) */
48 	uint_t sg_n;			/* engine N parameter (event count) */
49 	hrtime_t sg_t;			/* engine T parameter (nanoseconds) */
50 } fmd_serd_eng_t;
51 
52 #define	FMD_SERD_FIRED	0x1		/* error rate has exceeded threshold */
53 #define	FMD_SERD_DIRTY	0x2		/* engine needs to be checkpointed */
54 
55 typedef void fmd_serd_eng_f(fmd_serd_eng_t *, void *);
56 
57 typedef struct fmd_serd_hash {
58 	fmd_serd_eng_t **sh_hash;	/* hash bucket array for buffers */
59 	uint_t sh_hashlen;		/* length of hash bucket array */
60 	uint_t sh_count;		/* count of engines in hash */
61 } fmd_serd_hash_t;
62 
63 extern void fmd_serd_hash_create(fmd_serd_hash_t *);
64 extern void fmd_serd_hash_destroy(fmd_serd_hash_t *);
65 extern void fmd_serd_hash_apply(fmd_serd_hash_t *, fmd_serd_eng_f *, void *);
66 extern uint_t fmd_serd_hash_count(fmd_serd_hash_t *);
67 extern int fmd_serd_hash_contains(fmd_serd_hash_t *, fmd_event_t *);
68 
69 extern fmd_serd_eng_t *fmd_serd_eng_insert(fmd_serd_hash_t *,
70     const char *, uint32_t, hrtime_t);
71 
72 extern fmd_serd_eng_t *fmd_serd_eng_lookup(fmd_serd_hash_t *, const char *);
73 extern void fmd_serd_eng_delete(fmd_serd_hash_t *, const char *);
74 
75 extern int fmd_serd_eng_contains(fmd_serd_eng_t *, fmd_event_t *);
76 extern int fmd_serd_eng_record(void *, fmd_event_t *);
77 extern int fmd_serd_eng_fired(fmd_serd_eng_t *);
78 extern int fmd_serd_eng_empty(fmd_serd_eng_t *);
79 
80 extern void fmd_serd_eng_reset(fmd_serd_eng_t *);
81 extern void fmd_serd_eng_gc(fmd_serd_eng_t *, void *);
82 extern void fmd_serd_eng_commit(fmd_serd_eng_t *, void*);
83 extern void fmd_serd_eng_clrdirty(fmd_serd_eng_t *, void*);
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _FMD_SERD_H */
90