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