1*1ae08745Sheppo /* 2*1ae08745Sheppo * CDDL HEADER START 3*1ae08745Sheppo * 4*1ae08745Sheppo * The contents of this file are subject to the terms of the 5*1ae08745Sheppo * Common Development and Distribution License (the "License"). 6*1ae08745Sheppo * You may not use this file except in compliance with the License. 7*1ae08745Sheppo * 8*1ae08745Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1ae08745Sheppo * or http://www.opensolaris.org/os/licensing. 10*1ae08745Sheppo * See the License for the specific language governing permissions 11*1ae08745Sheppo * and limitations under the License. 12*1ae08745Sheppo * 13*1ae08745Sheppo * When distributing Covered Code, include this CDDL HEADER in each 14*1ae08745Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1ae08745Sheppo * If applicable, add the following below this CDDL HEADER, with the 16*1ae08745Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 17*1ae08745Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 18*1ae08745Sheppo * 19*1ae08745Sheppo * CDDL HEADER END 20*1ae08745Sheppo */ 21*1ae08745Sheppo 22*1ae08745Sheppo /* 23*1ae08745Sheppo * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*1ae08745Sheppo * Use is subject to license terms. 25*1ae08745Sheppo */ 26*1ae08745Sheppo 27*1ae08745Sheppo #ifndef _MDEG_H 28*1ae08745Sheppo #define _MDEG_H 29*1ae08745Sheppo 30*1ae08745Sheppo #pragma ident "%Z%%M% %I% %E% SMI" 31*1ae08745Sheppo 32*1ae08745Sheppo /* 33*1ae08745Sheppo * MD Event Generator (mdeg) interface. 34*1ae08745Sheppo */ 35*1ae08745Sheppo 36*1ae08745Sheppo #ifdef __cplusplus 37*1ae08745Sheppo extern "C" { 38*1ae08745Sheppo #endif 39*1ae08745Sheppo 40*1ae08745Sheppo #include <sys/mdesc.h> 41*1ae08745Sheppo 42*1ae08745Sheppo /* 43*1ae08745Sheppo * Specification of a node property. 44*1ae08745Sheppo */ 45*1ae08745Sheppo typedef struct { 46*1ae08745Sheppo uint8_t type; 47*1ae08745Sheppo char *namep; 48*1ae08745Sheppo union { 49*1ae08745Sheppo char *strp; 50*1ae08745Sheppo uint64_t val; 51*1ae08745Sheppo } _p; 52*1ae08745Sheppo 53*1ae08745Sheppo } mdeg_prop_spec_t; 54*1ae08745Sheppo 55*1ae08745Sheppo #define ps_str _p.strp 56*1ae08745Sheppo #define ps_val _p.val 57*1ae08745Sheppo 58*1ae08745Sheppo /* 59*1ae08745Sheppo * Specification of unique node in the MD. The array 60*1ae08745Sheppo * of property name value pairs is used to determine 61*1ae08745Sheppo * whether the node matches the specification. 62*1ae08745Sheppo */ 63*1ae08745Sheppo typedef struct { 64*1ae08745Sheppo char *namep; 65*1ae08745Sheppo mdeg_prop_spec_t *specp; 66*1ae08745Sheppo } mdeg_node_spec_t; 67*1ae08745Sheppo 68*1ae08745Sheppo /* 69*1ae08745Sheppo * Specification of a method to match nodes. The 70*1ae08745Sheppo * array of properties are used to match two nodes 71*1ae08745Sheppo * from different MDs. If the specified properties 72*1ae08745Sheppo * match, the nodes are the same. 73*1ae08745Sheppo */ 74*1ae08745Sheppo typedef struct { 75*1ae08745Sheppo char *namep; 76*1ae08745Sheppo md_prop_match_t *matchp; 77*1ae08745Sheppo } mdeg_node_match_t; 78*1ae08745Sheppo 79*1ae08745Sheppo /* 80*1ae08745Sheppo * The result of the MD update as communicated 81*1ae08745Sheppo * through the parameter to the registered callback. 82*1ae08745Sheppo */ 83*1ae08745Sheppo typedef struct { 84*1ae08745Sheppo md_t *mdp; 85*1ae08745Sheppo mde_cookie_t *mdep; 86*1ae08745Sheppo uint_t nelem; 87*1ae08745Sheppo } mdeg_diff_t; 88*1ae08745Sheppo 89*1ae08745Sheppo /* 90*1ae08745Sheppo * Results of the MD update for a specific registration 91*1ae08745Sheppo */ 92*1ae08745Sheppo typedef struct { 93*1ae08745Sheppo mdeg_diff_t added; 94*1ae08745Sheppo mdeg_diff_t removed; 95*1ae08745Sheppo mdeg_diff_t match_curr; 96*1ae08745Sheppo mdeg_diff_t match_prev; 97*1ae08745Sheppo } mdeg_result_t; 98*1ae08745Sheppo 99*1ae08745Sheppo /* 100*1ae08745Sheppo * Client Interface 101*1ae08745Sheppo */ 102*1ae08745Sheppo 103*1ae08745Sheppo #define MDEG_SUCCESS 0 104*1ae08745Sheppo #define MDEG_FAILURE 1 105*1ae08745Sheppo 106*1ae08745Sheppo typedef uint64_t mdeg_handle_t; 107*1ae08745Sheppo 108*1ae08745Sheppo typedef int (*mdeg_cb_t)(void *cb_argp, mdeg_result_t *resp); 109*1ae08745Sheppo 110*1ae08745Sheppo int mdeg_register(mdeg_node_spec_t *pspecp, mdeg_node_match_t *nmatchp, 111*1ae08745Sheppo mdeg_cb_t cb, void *cb_argp, mdeg_handle_t *hdlp); 112*1ae08745Sheppo 113*1ae08745Sheppo int mdeg_unregister(mdeg_handle_t hdl); 114*1ae08745Sheppo 115*1ae08745Sheppo 116*1ae08745Sheppo #ifdef __cplusplus 117*1ae08745Sheppo } 118*1ae08745Sheppo #endif 119*1ae08745Sheppo 120*1ae08745Sheppo #endif /* _MDEG_H */ 121