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_CASE_H 28 #define _FMD_CASE_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_list.h> 40 #include <fmd_api.h> 41 #include <fmd_buf.h> 42 43 struct fmd_module; /* see <fmd_module.h> */ 44 45 typedef struct fmd_case_item { 46 struct fmd_case_item *cit_next; /* pointer to next element in list */ 47 fmd_event_t *cit_event; /* pointer to held event */ 48 } fmd_case_item_t; 49 50 typedef struct fmd_case_susp { 51 struct fmd_case_susp *cis_next; /* pointer to next element in list */ 52 nvlist_t *cis_nvl; /* nvpair representing fault event */ 53 } fmd_case_susp_t; 54 55 typedef struct fmd_case_impl { 56 fmd_list_t ci_list; /* linked list next/prev pointers */ 57 struct fmd_case_impl *ci_next; /* next pointer for hash bucket chain */ 58 char *ci_uuid; /* uuid string for this case */ 59 uint_t ci_uuidlen; /* length of ci_uuid (not incl. \0) */ 60 struct fmd_module *ci_mod; /* module that owns this case */ 61 void *ci_data; /* data from fmd_case_setspecific() */ 62 pthread_mutex_t ci_lock; /* lock for remainder of contents */ 63 uint_t ci_refs; /* reference count */ 64 ushort_t ci_state; /* case state (see below) */ 65 ushort_t ci_flags; /* case flags (see below) */ 66 fmd_case_item_t *ci_items; /* list of items in this case */ 67 uint_t ci_nitems; /* number of ci_items */ 68 fmd_event_t *ci_principal; /* principal event (if any) */ 69 fmd_case_susp_t *ci_suspects; /* list of suspects in this case */ 70 uint_t ci_nsuspects; /* number of ci_suspects */ 71 size_t ci_nvsz; /* packed suspect nvlist array size */ 72 nvlist_t *ci_event; /* fma protocol list.suspects event */ 73 fmd_buf_hash_t ci_bufs; /* hash of bufs associated with case */ 74 } fmd_case_impl_t; 75 76 #define FMD_CASE_UNSOLVED 0 /* case is not yet solved (waiting) */ 77 #define FMD_CASE_SOLVED 1 /* case is solved (suspects added) */ 78 #define FMD_CASE_CLOSED 2 /* case is closed (reconfig done) */ 79 80 #define FMD_CF_DIRTY 0x1 /* case is in need of checkpoint */ 81 #define FMD_CF_REPAIR 0x2 /* case closed from external repair */ 82 83 typedef struct fmd_case_hash { 84 pthread_rwlock_t ch_lock; /* lock protecting case hash */ 85 fmd_case_impl_t **ch_hash; /* hash bucket array for cases */ 86 uint_t ch_hashlen; /* size of hash bucket array */ 87 } fmd_case_hash_t; 88 89 extern fmd_case_hash_t *fmd_case_hash_create(void); 90 extern void fmd_case_hash_destroy(fmd_case_hash_t *); 91 extern void fmd_case_hash_refresh(fmd_case_hash_t *); 92 extern fmd_case_t *fmd_case_hash_lookup(fmd_case_hash_t *, const char *); 93 94 extern fmd_case_t *fmd_case_create(struct fmd_module *, void *); 95 extern fmd_case_t *fmd_case_recreate(struct fmd_module *, const char *); 96 extern void fmd_case_destroy(fmd_case_t *); 97 extern void fmd_case_hold(fmd_case_t *); 98 extern void fmd_case_rele(fmd_case_t *); 99 100 extern void fmd_case_insert_principal(fmd_case_t *, fmd_event_t *); 101 extern void fmd_case_insert_event(fmd_case_t *, fmd_event_t *); 102 extern void fmd_case_insert_suspect(fmd_case_t *, nvlist_t *); 103 extern void fmd_case_reset_suspects(fmd_case_t *); 104 105 extern void fmd_case_transition(fmd_case_t *, uint_t); 106 extern void fmd_case_setdirty(fmd_case_t *); 107 extern void fmd_case_clrdirty(fmd_case_t *); 108 extern void fmd_case_commit(fmd_case_t *); 109 extern void fmd_case_update(fmd_case_t *); 110 111 extern int fmd_case_repair(fmd_case_t *); 112 extern int fmd_case_contains(fmd_case_t *, fmd_event_t *); 113 114 #ifdef __cplusplus 115 } 116 #endif 117 118 #endif /* _FMD_CASE_H */ 119