xref: /onnv-gate/usr/src/uts/sun4v/sys/mdeg.h (revision 3759:f817e8463cb0)
11991Sheppo /*
21991Sheppo  * CDDL HEADER START
31991Sheppo  *
41991Sheppo  * The contents of this file are subject to the terms of the
51991Sheppo  * Common Development and Distribution License (the "License").
61991Sheppo  * You may not use this file except in compliance with the License.
71991Sheppo  *
81991Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91991Sheppo  * or http://www.opensolaris.org/os/licensing.
101991Sheppo  * See the License for the specific language governing permissions
111991Sheppo  * and limitations under the License.
121991Sheppo  *
131991Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141991Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151991Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161991Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171991Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181991Sheppo  *
191991Sheppo  * CDDL HEADER END
201991Sheppo  */
211991Sheppo 
221991Sheppo /*
23*3759Srsmaeda  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
241991Sheppo  * Use is subject to license terms.
251991Sheppo  */
261991Sheppo 
271991Sheppo #ifndef _MDEG_H
281991Sheppo #define	_MDEG_H
291991Sheppo 
301991Sheppo #pragma ident	"%Z%%M%	%I%	%E% SMI"
311991Sheppo 
321991Sheppo /*
331991Sheppo  * MD Event Generator (mdeg) interface.
341991Sheppo  */
351991Sheppo 
361991Sheppo #ifdef __cplusplus
371991Sheppo extern "C" {
381991Sheppo #endif
391991Sheppo 
401991Sheppo #include <sys/mdesc.h>
411991Sheppo 
421991Sheppo /*
431991Sheppo  * Specification of a node property.
441991Sheppo  */
451991Sheppo typedef struct {
461991Sheppo 	uint8_t		type;
471991Sheppo 	char		*namep;
481991Sheppo 	union {
491991Sheppo 		char		*strp;
501991Sheppo 		uint64_t	val;
511991Sheppo 	} _p;
521991Sheppo 
531991Sheppo } mdeg_prop_spec_t;
541991Sheppo 
551991Sheppo #define	ps_str	_p.strp
561991Sheppo #define	ps_val	_p.val
571991Sheppo 
581991Sheppo /*
591991Sheppo  * Specification of unique node in the MD. The array
601991Sheppo  * of property name value pairs is used to determine
611991Sheppo  * whether the node matches the specification.
621991Sheppo  */
631991Sheppo typedef struct {
641991Sheppo 	char			*namep;
651991Sheppo 	mdeg_prop_spec_t	*specp;
661991Sheppo } mdeg_node_spec_t;
671991Sheppo 
681991Sheppo /*
691991Sheppo  * Specification of a method to match nodes. The
701991Sheppo  * array of properties are used to match two nodes
711991Sheppo  * from different MDs. If the specified properties
721991Sheppo  * match, the nodes are the same.
731991Sheppo  */
741991Sheppo typedef struct {
751991Sheppo 	char		*namep;
761991Sheppo 	md_prop_match_t	*matchp;
771991Sheppo } mdeg_node_match_t;
781991Sheppo 
791991Sheppo /*
801991Sheppo  * The result of the MD update as communicated
811991Sheppo  * through the parameter to the registered callback.
821991Sheppo  */
831991Sheppo typedef struct {
841991Sheppo 	md_t		*mdp;
851991Sheppo 	mde_cookie_t	*mdep;
86*3759Srsmaeda 	int		nelem;
871991Sheppo } mdeg_diff_t;
881991Sheppo 
891991Sheppo /*
901991Sheppo  * Results of the MD update for a specific registration
911991Sheppo  */
921991Sheppo typedef struct {
931991Sheppo 	mdeg_diff_t	added;
941991Sheppo 	mdeg_diff_t	removed;
951991Sheppo 	mdeg_diff_t	match_curr;
961991Sheppo 	mdeg_diff_t	match_prev;
971991Sheppo } mdeg_result_t;
981991Sheppo 
991991Sheppo /*
1001991Sheppo  * Client Interface
1011991Sheppo  */
1021991Sheppo 
1031991Sheppo #define	MDEG_SUCCESS	0
1041991Sheppo #define	MDEG_FAILURE	1
1051991Sheppo 
1061991Sheppo typedef uint64_t mdeg_handle_t;
1071991Sheppo 
1081991Sheppo typedef int (*mdeg_cb_t)(void *cb_argp, mdeg_result_t *resp);
1091991Sheppo 
1101991Sheppo int mdeg_register(mdeg_node_spec_t *pspecp, mdeg_node_match_t *nmatchp,
1111991Sheppo     mdeg_cb_t cb, void *cb_argp, mdeg_handle_t *hdlp);
1121991Sheppo 
1131991Sheppo int mdeg_unregister(mdeg_handle_t hdl);
1141991Sheppo 
1151991Sheppo 
1161991Sheppo #ifdef __cplusplus
1171991Sheppo }
1181991Sheppo #endif
1191991Sheppo 
1201991Sheppo #endif /* _MDEG_H */
121