10eb822a1Scindi /*
20eb822a1Scindi  * CDDL HEADER START
30eb822a1Scindi  *
40eb822a1Scindi  * The contents of this file are subject to the terms of the
50eb822a1Scindi  * Common Development and Distribution License (the "License").
60eb822a1Scindi  * You may not use this file except in compliance with the License.
70eb822a1Scindi  *
80eb822a1Scindi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90eb822a1Scindi  * or http://www.opensolaris.org/os/licensing.
100eb822a1Scindi  * See the License for the specific language governing permissions
110eb822a1Scindi  * and limitations under the License.
120eb822a1Scindi  *
130eb822a1Scindi  * When distributing Covered Code, include this CDDL HEADER in each
140eb822a1Scindi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150eb822a1Scindi  * If applicable, add the following below this CDDL HEADER, with the
160eb822a1Scindi  * fields enclosed by brackets "[]" replaced with your own identifying
170eb822a1Scindi  * information: Portions Copyright [yyyy] [name of copyright owner]
180eb822a1Scindi  *
190eb822a1Scindi  * CDDL HEADER END
200eb822a1Scindi  */
210eb822a1Scindi 
220eb822a1Scindi /*
2370818f58Stsien  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240eb822a1Scindi  * Use is subject to license terms.
250eb822a1Scindi  */
26ea30102cSRob Johnston /*
27*c5591576SRob Johnston  * Copyright 2020 Joyent, Inc.
28ea30102cSRob Johnston  */
290eb822a1Scindi #ifndef _TOPO_METHOD_H
300eb822a1Scindi #define	_TOPO_METHOD_H
310eb822a1Scindi 
320eb822a1Scindi #ifdef __cplusplus
330eb822a1Scindi extern "C" {
340eb822a1Scindi #endif
350eb822a1Scindi 
36940d71d2Seschrock #include <fm/topo_list.h>
37c40d7343Scindi 
38c40d7343Scindi typedef struct topo_imethod {
39c40d7343Scindi 	topo_list_t tim_list;		/* next/prev pointers */
40c40d7343Scindi 	pthread_mutex_t tim_lock;	/* method entry lock */
41c40d7343Scindi 	pthread_cond_t  tim_cv;		/* method entry cv */
42c40d7343Scindi 	uint_t tim_busy;		/* method entry busy indicator */
43c40d7343Scindi 	char *tim_name;			/* Method name */
44c40d7343Scindi 	topo_version_t tim_version;	/* Method version */
45c40d7343Scindi 	topo_stability_t tim_stability;	/* SMI stability of method */
46c40d7343Scindi 	char *tim_desc;			/* Method description */
47c40d7343Scindi 	topo_method_f *tim_func;	/* Method function */
48c40d7343Scindi 	struct topo_mod *tim_mod;	/* Ptr to controlling module */
49c40d7343Scindi } topo_imethod_t;
50c40d7343Scindi 
51c40d7343Scindi extern int topo_method_call(tnode_t *, const char *, topo_version_t, nvlist_t *,
52c40d7343Scindi     nvlist_t **, int *);
53c40d7343Scindi extern topo_imethod_t *topo_method_lookup(tnode_t *, const char *);
54c40d7343Scindi extern int topo_prop_method_version_register(tnode_t *, const char *,
55c40d7343Scindi     const char *, topo_type_t, const char *, topo_version_t, const nvlist_t *,
56c40d7343Scindi     int *);
57c40d7343Scindi 
580eb822a1Scindi /*
59ea30102cSRob Johnston  * These are for the private consumption of the sensor-transport fmd plugin
60ea30102cSRob Johnston  * and topo_method_sensor_failure()
61ea30102cSRob Johnston  */
62ea30102cSRob Johnston #define	ST_SPOOF_FMRI		"spoof_resource_fmri"
63ea30102cSRob Johnston #define	ST_SPOOF_SENSOR		"spoof_sensor_name"
64ea30102cSRob Johnston #define	ST_SPOOF_STATE		"spoof_sensor_state"
65ea30102cSRob Johnston 
66ea30102cSRob Johnston /*
670eb822a1Scindi  * FMRI methods
680eb822a1Scindi  */
690eb822a1Scindi #define	TOPO_METH_ASRU_COMPUTE		"topo_asru_compute"
700eb822a1Scindi #define	TOPO_METH_FRU_COMPUTE		"topo_fru_compute"
710eb822a1Scindi #define	TOPO_METH_FMRI			"topo_fmri"
720eb822a1Scindi #define	TOPO_METH_NVL2STR		"topo_nvl2str"
730eb822a1Scindi #define	TOPO_METH_STR2NVL		"topo_str2nvl"
740eb822a1Scindi #define	TOPO_METH_COMPARE		"topo_compare"
75c40d7343Scindi #define	TOPO_METH_PROP_GET		"topo_prop_get"
76c40d7343Scindi #define	TOPO_METH_PGRP_GET		"topo_pgrp_get"
77c40d7343Scindi #define	TOPO_METH_PROP_SET		"topo_prop_set"
78825ba0f2Srobj #define	TOPO_METH_FACILITY		"topo_facility"
798abca89fSRob Johnston #define	TOPO_METH_OCCUPIED		"topo_occupied"
80*c5591576SRob Johnston #define	TOPO_METH_PATH_STR2NVL		"topo_path_str2nvl"
81*c5591576SRob Johnston #define	TOPO_METH_PATH_NVL2STR		"topo_path_nvl2str"
82*c5591576SRob Johnston 
830eb822a1Scindi 
840eb822a1Scindi #define	TOPO_METH_FMRI_VERSION			0
850eb822a1Scindi #define	TOPO_METH_FRU_COMPUTE_VERSION		0
860eb822a1Scindi #define	TOPO_METH_ASRU_COMPUTE_VERSION		0
870eb822a1Scindi #define	TOPO_METH_NVL2STR_VERSION		0
880eb822a1Scindi #define	TOPO_METH_STR2NVL_VERSION		0
890eb822a1Scindi #define	TOPO_METH_COMPARE_VERSION		0
90c40d7343Scindi #define	TOPO_METH_PROP_GET_VERSION		0
91c40d7343Scindi #define	TOPO_METH_PGRP_GET_VERSION		0
92c40d7343Scindi #define	TOPO_METH_PROP_SET_VERSION		0
93825ba0f2Srobj #define	TOPO_METH_FACILITY_VERSION		0
948abca89fSRob Johnston #define	TOPO_METH_OCCUPIED_VERSION		0
950eb822a1Scindi 
960eb822a1Scindi #define	TOPO_METH_ASRU_COMPUTE_DESC	"Dynamic ASRU constructor"
970eb822a1Scindi #define	TOPO_METH_FRU_COMPUTE_DESC	"Dynamic FRU constructor"
980eb822a1Scindi #define	TOPO_METH_FMRI_DESC		"Dynamic FMRI constructor"
990eb822a1Scindi #define	TOPO_METH_NVL2STR_DESC		"FMRI to string"
1000eb822a1Scindi #define	TOPO_METH_STR2NVL_DESC		"string to FMRI"
1010eb822a1Scindi #define	TOPO_METH_COMPARE_DESC		"compare two FMRIs"
102c40d7343Scindi #define	TOPO_METH_PROP_GET_DESC		"get properties for FMRI"
103c40d7343Scindi #define	TOPO_METH_PGRP_GET_DESC		"get property group for FMRI"
104c40d7343Scindi #define	TOPO_METH_PROP_SET_DESC		"set properties for FMRI"
105825ba0f2Srobj #define	TOPO_METH_FACILITY_DESC		"get facility for FMRI"
1068abca89fSRob Johnston #define	TOPO_METH_OCCUPIED_DESC		"get occupant status"
107c40d7343Scindi 
10873e32a37SRobert Johnston #define	TOPO_METH_COMPARE_RET		"compare-return"
1098abca89fSRob Johnston #define	TOPO_METH_OCCUPIED_RET		"occupied-return"
1100eb822a1Scindi 
1110eb822a1Scindi #define	TOPO_METH_FMRI_ARG_NAME		"child-name"
1120eb822a1Scindi #define	TOPO_METH_FMRI_ARG_INST		"child-inst"
1130eb822a1Scindi #define	TOPO_METH_FMRI_ARG_NVL		"args"
1140eb822a1Scindi #define	TOPO_METH_FMRI_ARG_PARENT	"parent-fmri"
1150eb822a1Scindi #define	TOPO_METH_FMRI_ARG_AUTH		"auth"
1160eb822a1Scindi #define	TOPO_METH_FMRI_ARG_PART		"part"
1170eb822a1Scindi #define	TOPO_METH_FMRI_ARG_REV		"rev"
1180eb822a1Scindi #define	TOPO_METH_FMRI_ARG_SER		"serial"
1190eb822a1Scindi #define	TOPO_METH_FMRI_ARG_HCS		"hc-specific"
120c40d7343Scindi #define	TOPO_METH_FMRI_ARG_FMRI		"fmri"
121c40d7343Scindi #define	TOPO_METH_FMRI_ARG_SUBFMRI	"sub-fmri"
122c40d7343Scindi #define	TOPO_METH_FMRI_ARG_NV1		"nv1"
123c40d7343Scindi #define	TOPO_METH_FMRI_ARG_NV2		"nv2"
1240eb822a1Scindi 
1250eb822a1Scindi #ifdef	__cplusplus
1260eb822a1Scindi }
1270eb822a1Scindi #endif
1280eb822a1Scindi 
1290eb822a1Scindi #endif	/* _TOPO_METHOD_H */
130