xref: /titanic_50/usr/src/cmd/fm/modules/common/eversholt/itree.h (revision a6d42e7d71324c5193c3b94d57d96ba2925d52e1)
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 2008 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /* the "fault" field in the event struct requires the definition of nvlist_t */
39 #include <sys/fm/protocol.h>
40 #include <fm/fmd_api.h>
41 
42 /* Numerical representation of propagation N value (A), short for All */
43 #define	N_IS_ALL	-1
44 
45 /*
46  * effects_test event cached_state bits
47  * - reset on each call to effects_test()
48  */
49 #define	CREDIBLE_EFFECT 1
50 #define	WAIT_EFFECT 2
51 #define	PARENT_WAIT 4
52 
53 /*
54  * arrow mark bits (for K-count)
55  */
56 #define	EFFECTS_COUNTER 8
57 #define	REQMNTS_COUNTER 16
58 
59 /*
60  * requirements_test event cached_state bits
61  */
62 #define	REQMNTS_CREDIBLE 32
63 #define	REQMNTS_DISPROVED 64
64 #define	REQMNTS_WAIT 128
65 
66 /*
67  * requirements_test bubble mark bits
68  */
69 #define	BUBBLE_ELIDED 256
70 #define	BUBBLE_OK 512
71 
72 /*
73  * causes_test event cached_state bits
74  */
75 #define	CAUSES_TESTED 1024
76 
77 struct event {
78 	struct event *suspects;
79 	struct event *psuspects;
80 	struct event *observations;	/* for lists like suspect list */
81 	fmd_event_t *ffep;
82 	nvlist_t *nvp;			/* payload nvp for ereports */
83 	struct node *enode;		/* event node in parse tree */
84 	const struct ipath *ipp;	/* instanced version of event */
85 	struct lut *props;		/* instanced version of nvpairs */
86 	struct lut *payloadprops;	/* nvpairs for problem payload */
87 	struct lut *serdprops;		/* nvpairs for dynamic serd args */
88 	int count;			/* for reports, number seen */
89 	enum nametype t:3;		/* defined in tree.h */
90 	int is_suspect:1;		/* true if on suspect list */
91 	int keep_in_tree:1;
92 	int cached_state:11;
93 	unsigned long long cached_delay;
94 	struct bubble {
95 		struct bubble *next;
96 		struct event *myevent;
97 		int gen;		/* generation # */
98 		int nork;
99 		int mark:11;
100 		enum bubbletype {
101 			B_FROM,
102 			B_TO,
103 			B_INHIBIT
104 		} t:2;
105 		struct arrowlist {
106 			struct arrowlist *next;
107 			struct arrow {
108 				struct bubble *head;
109 				struct bubble *tail;
110 				/* prop node in parse tree */
111 				struct node *pnode;
112 				struct constraintlist {
113 					struct constraintlist *next;
114 					/* deferred constraints */
115 					struct node *cnode;
116 				} *constraints;
117 				int forever_false:1;
118 				int forever_true:1;
119 				int arrow_marked:1;
120 				int mark:11;
121 				unsigned long long mindelay;
122 				unsigned long long maxdelay;
123 			} *arrowp;
124 		} *arrows;
125 	} *bubbles;
126 };
127 
128 /*
129  * struct iterinfo is the stuff we store in the dictionary of iterators
130  * when we assign a value to an iterator.  it not only contains the value
131  * we assigned to the iterator, it contains a node pointer which we use to
132  * determine if we're the one that defined the value when popping [vh]match()
133  * recursion.
134  */
135 struct iterinfo {
136 	int num;
137 	struct node *np;
138 };
139 
140 struct lut *itree_create(struct config *croot);
141 void itree_free(struct lut *itp);
142 void itree_prune(struct lut *itp);
143 struct event *itree_lookup(struct lut *itp,
144     const char *ename, const struct ipath *ipp);
145 
146 struct arrowlist *itree_next_arrow(struct bubble *bubblep,
147     struct arrowlist *last);
148 struct bubble *itree_next_bubble(struct event *eventp, struct bubble *last);
149 struct constraintlist *itree_next_constraint(struct arrow *arrowp,
150     struct constraintlist *last);
151 
152 void itree_pevent_brief(int flags, struct event *eventp);
153 void itree_ptree(int flags, struct lut *itp);
154 
155 const char *itree_bubbletype2str(enum bubbletype t);
156 
157 void itree_fini(void);
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _EFT_ITREE_H */
164