xref: /illumos-gate/usr/src/cmd/fm/modules/common/eversholt/itree.h (revision 6e1fa242609208de48dfe1939b8814d4dff455a5)
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
500d0963fSdilpreet  * Common Development and Distribution License (the "License").
600d0963fSdilpreet  * 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  */
217c478bd9Sstevel@tonic-gate /*
22*6e1fa242SStephen Hanson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  * itree.h -- public definitions for itree module
267c478bd9Sstevel@tonic-gate  *
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef	_EFT_ITREE_H
307c478bd9Sstevel@tonic-gate #define	_EFT_ITREE_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /* the "fault" field in the event struct requires the definition of nvlist_t */
377c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
38b7d3956bSstephh #include <fm/fmd_api.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /* Numerical representation of propagation N value (A), short for All */
417c478bd9Sstevel@tonic-gate #define	N_IS_ALL	-1
427c478bd9Sstevel@tonic-gate 
437aec1d6eScindi /*
447aec1d6eScindi  * effects_test event cached_state bits
457aec1d6eScindi  * - reset on each call to effects_test()
467aec1d6eScindi  */
477aec1d6eScindi #define	CREDIBLE_EFFECT 1
487aec1d6eScindi #define	WAIT_EFFECT 2
497aec1d6eScindi #define	PARENT_WAIT 4
507aec1d6eScindi 
517aec1d6eScindi /*
527aec1d6eScindi  * arrow mark bits (for K-count)
537aec1d6eScindi  */
547aec1d6eScindi #define	EFFECTS_COUNTER 8
557aec1d6eScindi #define	REQMNTS_COUNTER 16
567aec1d6eScindi 
577aec1d6eScindi /*
587aec1d6eScindi  * requirements_test event cached_state bits
597aec1d6eScindi  */
607aec1d6eScindi #define	REQMNTS_CREDIBLE 32
617aec1d6eScindi #define	REQMNTS_DISPROVED 64
627aec1d6eScindi #define	REQMNTS_WAIT 128
637aec1d6eScindi 
647aec1d6eScindi /*
657aec1d6eScindi  * requirements_test bubble mark bits
667aec1d6eScindi  */
677aec1d6eScindi #define	BUBBLE_ELIDED 256
687aec1d6eScindi #define	BUBBLE_OK 512
697aec1d6eScindi 
707aec1d6eScindi /*
717aec1d6eScindi  * causes_test event cached_state bits
727aec1d6eScindi  */
737aec1d6eScindi #define	CAUSES_TESTED 1024
747aec1d6eScindi 
757c478bd9Sstevel@tonic-gate struct event {
767c478bd9Sstevel@tonic-gate 	struct event *suspects;
777c478bd9Sstevel@tonic-gate 	struct event *psuspects;
787c478bd9Sstevel@tonic-gate 	struct event *observations;	/* for lists like suspect list */
79b7d3956bSstephh 	fmd_event_t *ffep;
807c478bd9Sstevel@tonic-gate 	nvlist_t *nvp;			/* payload nvp for ereports */
817c478bd9Sstevel@tonic-gate 	struct node *enode;		/* event node in parse tree */
827c478bd9Sstevel@tonic-gate 	const struct ipath *ipp;	/* instanced version of event */
83*6e1fa242SStephen Hanson 	const struct ipath *ipp_un;	/* full version for Usednames */
847c478bd9Sstevel@tonic-gate 	struct lut *props;		/* instanced version of nvpairs */
857aec1d6eScindi 	struct lut *payloadprops;	/* nvpairs for problem payload */
86b7d3956bSstephh 	struct lut *serdprops;		/* nvpairs for dynamic serd args */
877c478bd9Sstevel@tonic-gate 	int count;			/* for reports, number seen */
88b5016cbbSstephh 	enum nametype t:3;		/* defined in tree.h */
89b5016cbbSstephh 	int is_suspect:1;		/* true if on suspect list */
90b5016cbbSstephh 	int keep_in_tree:1;
91b5016cbbSstephh 	int cached_state:11;
927aec1d6eScindi 	unsigned long long cached_delay;
937c478bd9Sstevel@tonic-gate 	struct bubble {
947c478bd9Sstevel@tonic-gate 		struct bubble *next;
95b5016cbbSstephh 		struct event *myevent;
967c478bd9Sstevel@tonic-gate 		int gen;		/* generation # */
97b5016cbbSstephh 		int nork;
98b5016cbbSstephh 		int mark:11;
997c478bd9Sstevel@tonic-gate 		enum bubbletype {
100b5016cbbSstephh 			B_FROM,
1017c478bd9Sstevel@tonic-gate 			B_TO,
1027c478bd9Sstevel@tonic-gate 			B_INHIBIT
103b5016cbbSstephh 		} t:2;
1047c478bd9Sstevel@tonic-gate 		struct arrowlist {
1057c478bd9Sstevel@tonic-gate 			struct arrowlist *next;
1067c478bd9Sstevel@tonic-gate 			struct arrow {
1077c478bd9Sstevel@tonic-gate 				struct bubble *head;
1087c478bd9Sstevel@tonic-gate 				struct bubble *tail;
1097c478bd9Sstevel@tonic-gate 				/* prop node in parse tree */
1107c478bd9Sstevel@tonic-gate 				struct node *pnode;
1117c478bd9Sstevel@tonic-gate 				struct constraintlist {
1127c478bd9Sstevel@tonic-gate 					struct constraintlist *next;
1137c478bd9Sstevel@tonic-gate 					/* deferred constraints */
1147c478bd9Sstevel@tonic-gate 					struct node *cnode;
1157c478bd9Sstevel@tonic-gate 				} *constraints;
116b5016cbbSstephh 				int forever_false:1;
117b5016cbbSstephh 				int forever_true:1;
118b5016cbbSstephh 				int arrow_marked:1;
119b5016cbbSstephh 				int mark:11;
1207c478bd9Sstevel@tonic-gate 				unsigned long long mindelay;
1217c478bd9Sstevel@tonic-gate 				unsigned long long maxdelay;
1227c478bd9Sstevel@tonic-gate 			} *arrowp;
1237c478bd9Sstevel@tonic-gate 		} *arrows;
1247c478bd9Sstevel@tonic-gate 	} *bubbles;
1257c478bd9Sstevel@tonic-gate };
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * struct iterinfo is the stuff we store in the dictionary of iterators
1297c478bd9Sstevel@tonic-gate  * when we assign a value to an iterator.  it not only contains the value
1307c478bd9Sstevel@tonic-gate  * we assigned to the iterator, it contains a node pointer which we use to
1317c478bd9Sstevel@tonic-gate  * determine if we're the one that defined the value when popping [vh]match()
1327c478bd9Sstevel@tonic-gate  * recursion.
1337c478bd9Sstevel@tonic-gate  */
1347c478bd9Sstevel@tonic-gate struct iterinfo {
1357c478bd9Sstevel@tonic-gate 	int num;
1367c478bd9Sstevel@tonic-gate 	struct node *np;
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate struct lut *itree_create(struct config *croot);
1407c478bd9Sstevel@tonic-gate void itree_free(struct lut *itp);
14100d0963fSdilpreet void itree_prune(struct lut *itp);
1427c478bd9Sstevel@tonic-gate struct event *itree_lookup(struct lut *itp,
1437c478bd9Sstevel@tonic-gate     const char *ename, const struct ipath *ipp);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate struct arrowlist *itree_next_arrow(struct bubble *bubblep,
1467c478bd9Sstevel@tonic-gate     struct arrowlist *last);
1477c478bd9Sstevel@tonic-gate struct bubble *itree_next_bubble(struct event *eventp, struct bubble *last);
1487c478bd9Sstevel@tonic-gate struct constraintlist *itree_next_constraint(struct arrow *arrowp,
1497c478bd9Sstevel@tonic-gate     struct constraintlist *last);
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate void itree_pevent_brief(int flags, struct event *eventp);
1527c478bd9Sstevel@tonic-gate void itree_ptree(int flags, struct lut *itp);
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate const char *itree_bubbletype2str(enum bubbletype t);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate void itree_fini(void);
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1597c478bd9Sstevel@tonic-gate }
1607c478bd9Sstevel@tonic-gate #endif
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate #endif	/* _EFT_ITREE_H */
163