xref: /titanic_41/usr/src/cmd/fm/modules/common/eversholt/itree.h (revision 430b4c467020edf2445feb0c21db01c88b86243a)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * itree.h -- public definitions for itree module
26  *
27  */
28 
29 #ifndef	_EFT_ITREE_H
30 #define	_EFT_ITREE_H
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /* the "fault" field in the event struct requires the definition of nvlist_t */
37 #include <sys/fm/protocol.h>
38 #include <fm/fmd_api.h>
39 
40 /* Numerical representation of propagation N value (A), short for All */
41 #define	N_IS_ALL	-1
42 
43 /*
44  * effects_test event cached_state bits
45  * - reset on each call to effects_test()
46  */
47 #define	CREDIBLE_EFFECT 1
48 #define	WAIT_EFFECT 2
49 #define	PARENT_WAIT 4
50 
51 /*
52  * arrow mark bits (for K-count)
53  */
54 #define	EFFECTS_COUNTER 8
55 #define	REQMNTS_COUNTER 16
56 
57 /*
58  * requirements_test event cached_state bits
59  */
60 #define	REQMNTS_CREDIBLE 32
61 #define	REQMNTS_DISPROVED 64
62 #define	REQMNTS_WAIT 128
63 
64 /*
65  * requirements_test bubble mark bits
66  */
67 #define	BUBBLE_ELIDED 256
68 #define	BUBBLE_OK 512
69 
70 /*
71  * causes_test event cached_state bits
72  */
73 #define	CAUSES_TESTED 1024
74 
75 struct event {
76 	struct event *suspects;
77 	struct event *psuspects;
78 	struct event *observations;	/* for lists like suspect list */
79 	fmd_event_t *ffep;
80 	nvlist_t *nvp;			/* payload nvp for ereports */
81 	struct node *enode;		/* event node in parse tree */
82 	const struct ipath *ipp;	/* instanced version of event */
83 	const struct ipath *ipp_un;	/* full version for Usednames */
84 	struct lut *props;		/* instanced version of nvpairs */
85 	struct lut *payloadprops;	/* nvpairs for problem payload */
86 	struct lut *serdprops;		/* nvpairs for dynamic serd args */
87 	int count;			/* for reports, number seen */
88 	enum nametype t:3;		/* defined in tree.h */
89 	int is_suspect:1;		/* true if on suspect list */
90 	int keep_in_tree:1;
91 	int cached_state:11;
92 	unsigned long long cached_delay;
93 	struct bubble {
94 		struct bubble *next;
95 		struct event *myevent;
96 		int gen;		/* generation # */
97 		int nork;
98 		int mark:11;
99 		enum bubbletype {
100 			B_FROM,
101 			B_TO,
102 			B_INHIBIT
103 		} t:2;
104 		struct arrowlist {
105 			struct arrowlist *next;
106 			struct arrow {
107 				struct bubble *head;
108 				struct bubble *tail;
109 				/* prop node in parse tree */
110 				struct node *pnode;
111 				struct constraintlist {
112 					struct constraintlist *next;
113 					/* deferred constraints */
114 					struct node *cnode;
115 				} *constraints;
116 				int forever_false:1;
117 				int forever_true:1;
118 				int arrow_marked:1;
119 				int mark:11;
120 				unsigned long long mindelay;
121 				unsigned long long maxdelay;
122 			} *arrowp;
123 		} *arrows;
124 	} *bubbles;
125 };
126 
127 /*
128  * struct iterinfo is the stuff we store in the dictionary of iterators
129  * when we assign a value to an iterator.  it not only contains the value
130  * we assigned to the iterator, it contains a node pointer which we use to
131  * determine if we're the one that defined the value when popping [vh]match()
132  * recursion.
133  */
134 struct iterinfo {
135 	int num;
136 	struct node *np;
137 };
138 
139 struct lut *itree_create(struct config *croot);
140 void itree_free(struct lut *itp);
141 void itree_prune(struct lut *itp);
142 struct event *itree_lookup(struct lut *itp,
143     const char *ename, const struct ipath *ipp);
144 
145 struct arrowlist *itree_next_arrow(struct bubble *bubblep,
146     struct arrowlist *last);
147 struct bubble *itree_next_bubble(struct event *eventp, struct bubble *last);
148 struct constraintlist *itree_next_constraint(struct arrow *arrowp,
149     struct constraintlist *last);
150 
151 void itree_pevent_brief(int flags, struct event *eventp);
152 void itree_ptree(int flags, struct lut *itp);
153 
154 const char *itree_bubbletype2str(enum bubbletype t);
155 
156 void itree_fini(void);
157 
158 #ifdef	__cplusplus
159 }
160 #endif
161 
162 #endif	/* _EFT_ITREE_H */
163