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