10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51303Swesolows * Common Development and Distribution License (the "License"). 61303Swesolows * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211193Smws 220Sstevel@tonic-gate /* 23*12967Sgavin.maltby@oracle.com * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _FMD_CASE_H 270Sstevel@tonic-gate #define _FMD_CASE_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <pthread.h> 300Sstevel@tonic-gate #include <libnvpair.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <fmd_list.h> 370Sstevel@tonic-gate #include <fmd_api.h> 380Sstevel@tonic-gate #include <fmd_buf.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate struct fmd_module; /* see <fmd_module.h> */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate typedef struct fmd_case_item { 430Sstevel@tonic-gate struct fmd_case_item *cit_next; /* pointer to next element in list */ 440Sstevel@tonic-gate fmd_event_t *cit_event; /* pointer to held event */ 450Sstevel@tonic-gate } fmd_case_item_t; 460Sstevel@tonic-gate 470Sstevel@tonic-gate typedef struct fmd_case_susp { 480Sstevel@tonic-gate struct fmd_case_susp *cis_next; /* pointer to next element in list */ 490Sstevel@tonic-gate nvlist_t *cis_nvl; /* nvpair representing fault event */ 500Sstevel@tonic-gate } fmd_case_susp_t; 510Sstevel@tonic-gate 520Sstevel@tonic-gate typedef struct fmd_case_impl { 530Sstevel@tonic-gate fmd_list_t ci_list; /* linked list next/prev pointers */ 540Sstevel@tonic-gate struct fmd_case_impl *ci_next; /* next pointer for hash bucket chain */ 556228Sstephh struct fmd_case_impl *ci_code_next; /* ci_code hash bucket chain */ 560Sstevel@tonic-gate char *ci_uuid; /* uuid string for this case */ 570Sstevel@tonic-gate uint_t ci_uuidlen; /* length of ci_uuid (not incl. \0) */ 581193Smws char *ci_code; /* code associated with this case */ 591193Smws size_t ci_codelen; /* size of ci_code buffer in bytes */ 600Sstevel@tonic-gate struct fmd_module *ci_mod; /* module that owns this case */ 611193Smws fmd_xprt_t *ci_xprt; /* transport for this case (or NULL) */ 629120SStephen.Hanson@Sun.COM uint8_t ci_precanned; /* precanned code from injection */ 639120SStephen.Hanson@Sun.COM nvlist_t *ci_diag_de; /* diag side de fmri */ 649120SStephen.Hanson@Sun.COM uint8_t *ci_diag_asru; /* is asru valid on diag side */ 659120SStephen.Hanson@Sun.COM uint8_t *ci_proxy_asru; /* is asru valid on proxy side */ 660Sstevel@tonic-gate void *ci_data; /* data from fmd_case_setspecific() */ 670Sstevel@tonic-gate pthread_mutex_t ci_lock; /* lock for remainder of contents */ 680Sstevel@tonic-gate uint_t ci_refs; /* reference count */ 690Sstevel@tonic-gate ushort_t ci_state; /* case state (see below) */ 700Sstevel@tonic-gate ushort_t ci_flags; /* case flags (see below) */ 710Sstevel@tonic-gate fmd_case_item_t *ci_items; /* list of items in this case */ 720Sstevel@tonic-gate uint_t ci_nitems; /* number of ci_items */ 730Sstevel@tonic-gate fmd_event_t *ci_principal; /* principal event (if any) */ 740Sstevel@tonic-gate fmd_case_susp_t *ci_suspects; /* list of suspects in this case */ 750Sstevel@tonic-gate uint_t ci_nsuspects; /* number of ci_suspects */ 760Sstevel@tonic-gate size_t ci_nvsz; /* packed suspect nvlist array size */ 770Sstevel@tonic-gate fmd_buf_hash_t ci_bufs; /* hash of bufs associated with case */ 785255Sstephh struct timeval ci_tv; /* time of original diagnosis */ 795255Sstephh int ci_tv_valid; /* time of original diagnosis valid */ 8010928SStephen.Hanson@Sun.COM int ci_injected; /* was the fault injected */ 810Sstevel@tonic-gate } fmd_case_impl_t; 820Sstevel@tonic-gate 831193Smws #define FMD_CASE_CURRENT -1u /* flag for current state */ 841193Smws 850Sstevel@tonic-gate #define FMD_CASE_UNSOLVED 0 /* case is not yet solved (waiting) */ 860Sstevel@tonic-gate #define FMD_CASE_SOLVED 1 /* case is solved (suspects added) */ 871193Smws #define FMD_CASE_CLOSE_WAIT 2 /* case is executing fmdo_close() */ 881193Smws #define FMD_CASE_CLOSED 3 /* case is closed (reconfig done) */ 897275Sstephh #define FMD_CASE_REPAIRED 4 /* case is repaired */ 907275Sstephh #define FMD_CASE_RESOLVED 5 /* case is resolved (can be freed) */ 910Sstevel@tonic-gate 921552Smws #define FMD_CF_DIRTY 0x01 /* case is in need of checkpoint */ 931552Smws #define FMD_CF_SOLVED 0x02 /* case has been solved */ 941552Smws #define FMD_CF_ISOLATED 0x04 /* case has been isolated */ 951552Smws #define FMD_CF_REPAIRED 0x08 /* case has been repaired */ 969120SStephen.Hanson@Sun.COM #define FMD_CF_RESOLVED 0x10 /* case has been resolved */ 975255Sstephh #define FMD_CF_INVISIBLE 0x20 /* case should be invisible */ 986081Scy152378 #define FMD_CF_DELETING 0x40 /* case is about to be deleted */ 9910656SStephen.Hanson@Sun.COM #define FMD_CF_RES_CMPL 0x80 /* transition to resolved is complete */ 1000Sstevel@tonic-gate 1019120SStephen.Hanson@Sun.COM /* 1029120SStephen.Hanson@Sun.COM * ci_proxy_asru flags record if we created a new asru on the proxy side and 1039120SStephen.Hanson@Sun.COM * if so whether it is derived from the received asru or received resource. 1049120SStephen.Hanson@Sun.COM */ 1059120SStephen.Hanson@Sun.COM #define FMD_PROXY_ASRU_NOT_NEEDED 0 1069120SStephen.Hanson@Sun.COM #define FMD_PROXY_ASRU_FROM_ASRU 1 1079120SStephen.Hanson@Sun.COM #define FMD_PROXY_ASRU_FROM_RSRC 2 1089120SStephen.Hanson@Sun.COM 1090Sstevel@tonic-gate typedef struct fmd_case_hash { 1100Sstevel@tonic-gate pthread_rwlock_t ch_lock; /* lock protecting case hash */ 1110Sstevel@tonic-gate fmd_case_impl_t **ch_hash; /* hash bucket array for cases */ 1126228Sstephh fmd_case_impl_t **ch_code_hash; /* ci_code hash bucket array */ 1130Sstevel@tonic-gate uint_t ch_hashlen; /* size of hash bucket array */ 1141193Smws uint_t ch_count; /* number of cases in hash */ 1150Sstevel@tonic-gate } fmd_case_hash_t; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate extern fmd_case_hash_t *fmd_case_hash_create(void); 1180Sstevel@tonic-gate extern void fmd_case_hash_destroy(fmd_case_hash_t *); 1190Sstevel@tonic-gate extern fmd_case_t *fmd_case_hash_lookup(fmd_case_hash_t *, const char *); 1201193Smws extern void fmd_case_hash_apply(fmd_case_hash_t *, 1211193Smws void (*)(fmd_case_t *, void *), void *); 1220Sstevel@tonic-gate 123*12967Sgavin.maltby@oracle.com extern fmd_case_t *fmd_case_create(struct fmd_module *, const char *, void *); 1241193Smws extern fmd_case_t *fmd_case_recreate(struct fmd_module *, 1251193Smws struct fmd_xprt *, uint_t, const char *, const char *); 1261193Smws extern void fmd_case_destroy(fmd_case_t *, int); 1270Sstevel@tonic-gate extern void fmd_case_hold(fmd_case_t *); 1281193Smws extern void fmd_case_hold_locked(fmd_case_t *); 1290Sstevel@tonic-gate extern void fmd_case_rele(fmd_case_t *); 1306228Sstephh extern void fmd_case_rele_locked(fmd_case_t *); 1316228Sstephh extern void fmd_case_update(fmd_case_t *); 1320Sstevel@tonic-gate 1331414Scindi extern int fmd_case_insert_principal(fmd_case_t *, fmd_event_t *); 1341414Scindi extern int fmd_case_insert_event(fmd_case_t *, fmd_event_t *); 1351414Scindi 1360Sstevel@tonic-gate extern void fmd_case_insert_suspect(fmd_case_t *, nvlist_t *); 1371193Smws extern void fmd_case_recreate_suspect(fmd_case_t *, nvlist_t *); 1380Sstevel@tonic-gate extern void fmd_case_reset_suspects(fmd_case_t *); 1390Sstevel@tonic-gate 1401193Smws extern nvlist_t *fmd_case_mkevent(fmd_case_t *, const char *); 1411193Smws extern void fmd_case_publish(fmd_case_t *, uint_t); 1421193Smws extern void fmd_case_transition(fmd_case_t *, uint_t, uint_t); 1431429Smws extern void fmd_case_transition_update(fmd_case_t *, uint_t, uint_t); 1440Sstevel@tonic-gate extern void fmd_case_setdirty(fmd_case_t *); 1450Sstevel@tonic-gate extern void fmd_case_clrdirty(fmd_case_t *); 1460Sstevel@tonic-gate extern void fmd_case_commit(fmd_case_t *); 1470Sstevel@tonic-gate extern void fmd_case_update(fmd_case_t *); 1481193Smws extern void fmd_case_delete(fmd_case_t *); 1499120SStephen.Hanson@Sun.COM extern void fmd_case_discard(fmd_case_t *, boolean_t); 1505255Sstephh extern void fmd_case_settime(fmd_case_t *, time_t, suseconds_t); 1519120SStephen.Hanson@Sun.COM extern void fmd_case_setcode(fmd_case_t *, char *); 1529120SStephen.Hanson@Sun.COM extern void fmd_case_set_de_fmri(fmd_case_t *, nvlist_t *); 15310928SStephen.Hanson@Sun.COM extern void fmd_case_set_injected(fmd_case_t *); 1549120SStephen.Hanson@Sun.COM extern void fmd_case_update_status(fmd_case_t *, uint8_t *, uint8_t *, 1559120SStephen.Hanson@Sun.COM uint8_t *); 1569120SStephen.Hanson@Sun.COM extern void fmd_case_update_containees(fmd_case_t *); 1579120SStephen.Hanson@Sun.COM extern void fmd_case_xprt_updated(fmd_case_t *); 1589120SStephen.Hanson@Sun.COM extern void fmd_case_close_status(fmd_case_t *); 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate extern int fmd_case_repair(fmd_case_t *); 1617275Sstephh extern int fmd_case_acquit(fmd_case_t *); 1620Sstevel@tonic-gate extern int fmd_case_contains(fmd_case_t *, fmd_event_t *); 1631193Smws extern int fmd_case_orphaned(fmd_case_t *); 1647275Sstephh extern void fmd_case_repair_replay(void); 16510656SStephen.Hanson@Sun.COM extern void fmd_case_discard_resolved(fmd_case_t *, void *); 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate #ifdef __cplusplus 1680Sstevel@tonic-gate } 1690Sstevel@tonic-gate #endif 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate #endif /* _FMD_CASE_H */ 172