xref: /titanic_41/usr/src/uts/sun4v/sys/mdeg.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MDEG_H
28 #define	_MDEG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * MD Event Generator (mdeg) interface.
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/mdesc.h>
41 
42 /*
43  * Specification of a node property.
44  */
45 typedef struct {
46 	uint8_t		type;
47 	char		*namep;
48 	union {
49 		char		*strp;
50 		uint64_t	val;
51 	} _p;
52 
53 } mdeg_prop_spec_t;
54 
55 #define	ps_str	_p.strp
56 #define	ps_val	_p.val
57 
58 /*
59  * Specification of unique node in the MD. The array
60  * of property name value pairs is used to determine
61  * whether the node matches the specification.
62  */
63 typedef struct {
64 	char			*namep;
65 	mdeg_prop_spec_t	*specp;
66 } mdeg_node_spec_t;
67 
68 /*
69  * Specification of a method to match nodes. The
70  * array of properties are used to match two nodes
71  * from different MDs. If the specified properties
72  * match, the nodes are the same.
73  */
74 typedef struct {
75 	char		*namep;
76 	md_prop_match_t	*matchp;
77 } mdeg_node_match_t;
78 
79 /*
80  * The result of the MD update as communicated
81  * through the parameter to the registered callback.
82  */
83 typedef struct {
84 	md_t		*mdp;
85 	mde_cookie_t	*mdep;
86 	uint_t		nelem;
87 } mdeg_diff_t;
88 
89 /*
90  * Results of the MD update for a specific registration
91  */
92 typedef struct {
93 	mdeg_diff_t	added;
94 	mdeg_diff_t	removed;
95 	mdeg_diff_t	match_curr;
96 	mdeg_diff_t	match_prev;
97 } mdeg_result_t;
98 
99 /*
100  * Client Interface
101  */
102 
103 #define	MDEG_SUCCESS	0
104 #define	MDEG_FAILURE	1
105 
106 typedef uint64_t mdeg_handle_t;
107 
108 typedef int (*mdeg_cb_t)(void *cb_argp, mdeg_result_t *resp);
109 
110 int mdeg_register(mdeg_node_spec_t *pspecp, mdeg_node_match_t *nmatchp,
111     mdeg_cb_t cb, void *cb_argp, mdeg_handle_t *hdlp);
112 
113 int mdeg_unregister(mdeg_handle_t hdl);
114 
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* _MDEG_H */
121