11ae08745Sheppo /* 21ae08745Sheppo * CDDL HEADER START 31ae08745Sheppo * 41ae08745Sheppo * The contents of this file are subject to the terms of the 51ae08745Sheppo * Common Development and Distribution License (the "License"). 61ae08745Sheppo * You may not use this file except in compliance with the License. 71ae08745Sheppo * 81ae08745Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91ae08745Sheppo * or http://www.opensolaris.org/os/licensing. 101ae08745Sheppo * See the License for the specific language governing permissions 111ae08745Sheppo * and limitations under the License. 121ae08745Sheppo * 131ae08745Sheppo * When distributing Covered Code, include this CDDL HEADER in each 141ae08745Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151ae08745Sheppo * If applicable, add the following below this CDDL HEADER, with the 161ae08745Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 171ae08745Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 181ae08745Sheppo * 191ae08745Sheppo * CDDL HEADER END 201ae08745Sheppo */ 211ae08745Sheppo 221ae08745Sheppo /* 23*4e476149Srsmaeda * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 241ae08745Sheppo * Use is subject to license terms. 251ae08745Sheppo */ 261ae08745Sheppo 271ae08745Sheppo #ifndef _MDEG_H 281ae08745Sheppo #define _MDEG_H 291ae08745Sheppo 301ae08745Sheppo #pragma ident "%Z%%M% %I% %E% SMI" 311ae08745Sheppo 321ae08745Sheppo /* 331ae08745Sheppo * MD Event Generator (mdeg) interface. 341ae08745Sheppo */ 351ae08745Sheppo 361ae08745Sheppo #ifdef __cplusplus 371ae08745Sheppo extern "C" { 381ae08745Sheppo #endif 391ae08745Sheppo 401ae08745Sheppo #include <sys/mdesc.h> 411ae08745Sheppo 421ae08745Sheppo /* 431ae08745Sheppo * Specification of a node property. 441ae08745Sheppo */ 451ae08745Sheppo typedef struct { 461ae08745Sheppo uint8_t type; 471ae08745Sheppo char *namep; 481ae08745Sheppo union { 491ae08745Sheppo char *strp; 501ae08745Sheppo uint64_t val; 511ae08745Sheppo } _p; 521ae08745Sheppo 531ae08745Sheppo } mdeg_prop_spec_t; 541ae08745Sheppo 551ae08745Sheppo #define ps_str _p.strp 561ae08745Sheppo #define ps_val _p.val 571ae08745Sheppo 581ae08745Sheppo /* 591ae08745Sheppo * Specification of unique node in the MD. The array 601ae08745Sheppo * of property name value pairs is used to determine 611ae08745Sheppo * whether the node matches the specification. 621ae08745Sheppo */ 631ae08745Sheppo typedef struct { 641ae08745Sheppo char *namep; 651ae08745Sheppo mdeg_prop_spec_t *specp; 661ae08745Sheppo } mdeg_node_spec_t; 671ae08745Sheppo 681ae08745Sheppo /* 691ae08745Sheppo * Specification of a method to match nodes. The 701ae08745Sheppo * array of properties are used to match two nodes 711ae08745Sheppo * from different MDs. If the specified properties 721ae08745Sheppo * match, the nodes are the same. 731ae08745Sheppo */ 741ae08745Sheppo typedef struct { 751ae08745Sheppo char *namep; 761ae08745Sheppo md_prop_match_t *matchp; 771ae08745Sheppo } mdeg_node_match_t; 781ae08745Sheppo 791ae08745Sheppo /* 801ae08745Sheppo * The result of the MD update as communicated 811ae08745Sheppo * through the parameter to the registered callback. 821ae08745Sheppo */ 831ae08745Sheppo typedef struct { 841ae08745Sheppo md_t *mdp; 851ae08745Sheppo mde_cookie_t *mdep; 86*4e476149Srsmaeda int nelem; 871ae08745Sheppo } mdeg_diff_t; 881ae08745Sheppo 891ae08745Sheppo /* 901ae08745Sheppo * Results of the MD update for a specific registration 911ae08745Sheppo */ 921ae08745Sheppo typedef struct { 931ae08745Sheppo mdeg_diff_t added; 941ae08745Sheppo mdeg_diff_t removed; 951ae08745Sheppo mdeg_diff_t match_curr; 961ae08745Sheppo mdeg_diff_t match_prev; 971ae08745Sheppo } mdeg_result_t; 981ae08745Sheppo 991ae08745Sheppo /* 1001ae08745Sheppo * Client Interface 1011ae08745Sheppo */ 1021ae08745Sheppo 1031ae08745Sheppo #define MDEG_SUCCESS 0 1041ae08745Sheppo #define MDEG_FAILURE 1 1051ae08745Sheppo 1061ae08745Sheppo typedef uint64_t mdeg_handle_t; 1071ae08745Sheppo 1081ae08745Sheppo typedef int (*mdeg_cb_t)(void *cb_argp, mdeg_result_t *resp); 1091ae08745Sheppo 1101ae08745Sheppo int mdeg_register(mdeg_node_spec_t *pspecp, mdeg_node_match_t *nmatchp, 1111ae08745Sheppo mdeg_cb_t cb, void *cb_argp, mdeg_handle_t *hdlp); 1121ae08745Sheppo 1131ae08745Sheppo int mdeg_unregister(mdeg_handle_t hdl); 1141ae08745Sheppo 1151ae08745Sheppo 1161ae08745Sheppo #ifdef __cplusplus 1171ae08745Sheppo } 1181ae08745Sheppo #endif 1191ae08745Sheppo 1201ae08745Sheppo #endif /* _MDEG_H */ 121