xref: /illumos-gate/usr/src/lib/fm/topo/libtopo/common/topo_method.h (revision 6523a3aa7f325d64841382707603be7a86e68147)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * Copyright 2020 Joyent, Inc.
28  */
29 #ifndef _TOPO_METHOD_H
30 #define	_TOPO_METHOD_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <fm/topo_list.h>
37 
38 typedef struct topo_imethod {
39 	topo_list_t tim_list;		/* next/prev pointers */
40 	pthread_mutex_t tim_lock;	/* method entry lock */
41 	pthread_cond_t  tim_cv;		/* method entry cv */
42 	uint_t tim_busy;		/* method entry busy indicator */
43 	char *tim_name;			/* Method name */
44 	topo_version_t tim_version;	/* Method version */
45 	topo_stability_t tim_stability;	/* SMI stability of method */
46 	char *tim_desc;			/* Method description */
47 	topo_method_f *tim_func;	/* Method function */
48 	struct topo_mod *tim_mod;	/* Ptr to controlling module */
49 } topo_imethod_t;
50 
51 extern int topo_method_call(tnode_t *, const char *, topo_version_t, nvlist_t *,
52     nvlist_t **, int *);
53 extern topo_imethod_t *topo_method_lookup(tnode_t *, const char *);
54 extern int topo_prop_method_version_register(tnode_t *, const char *,
55     const char *, topo_type_t, const char *, topo_version_t, const nvlist_t *,
56     int *);
57 
58 /*
59  * These are for the private consumption of the sensor-transport fmd plugin
60  * and topo_method_sensor_failure()
61  */
62 #define	ST_SPOOF_FMRI		"spoof_resource_fmri"
63 #define	ST_SPOOF_SENSOR		"spoof_sensor_name"
64 #define	ST_SPOOF_STATE		"spoof_sensor_state"
65 
66 /*
67  * FMRI methods
68  */
69 #define	TOPO_METH_ASRU_COMPUTE		"topo_asru_compute"
70 #define	TOPO_METH_FRU_COMPUTE		"topo_fru_compute"
71 #define	TOPO_METH_FMRI			"topo_fmri"
72 #define	TOPO_METH_NVL2STR		"topo_nvl2str"
73 #define	TOPO_METH_STR2NVL		"topo_str2nvl"
74 #define	TOPO_METH_COMPARE		"topo_compare"
75 #define	TOPO_METH_PROP_GET		"topo_prop_get"
76 #define	TOPO_METH_PGRP_GET		"topo_pgrp_get"
77 #define	TOPO_METH_PROP_SET		"topo_prop_set"
78 #define	TOPO_METH_FACILITY		"topo_facility"
79 #define	TOPO_METH_OCCUPIED		"topo_occupied"
80 #define	TOPO_METH_PATH_STR2NVL		"topo_path_str2nvl"
81 #define	TOPO_METH_PATH_NVL2STR		"topo_path_nvl2str"
82 
83 
84 #define	TOPO_METH_FMRI_VERSION			0
85 #define	TOPO_METH_FRU_COMPUTE_VERSION		0
86 #define	TOPO_METH_ASRU_COMPUTE_VERSION		0
87 #define	TOPO_METH_NVL2STR_VERSION		0
88 #define	TOPO_METH_STR2NVL_VERSION		0
89 #define	TOPO_METH_COMPARE_VERSION		0
90 #define	TOPO_METH_PROP_GET_VERSION		0
91 #define	TOPO_METH_PGRP_GET_VERSION		0
92 #define	TOPO_METH_PROP_SET_VERSION		0
93 #define	TOPO_METH_FACILITY_VERSION		0
94 #define	TOPO_METH_OCCUPIED_VERSION		0
95 
96 #define	TOPO_METH_ASRU_COMPUTE_DESC	"Dynamic ASRU constructor"
97 #define	TOPO_METH_FRU_COMPUTE_DESC	"Dynamic FRU constructor"
98 #define	TOPO_METH_FMRI_DESC		"Dynamic FMRI constructor"
99 #define	TOPO_METH_NVL2STR_DESC		"FMRI to string"
100 #define	TOPO_METH_STR2NVL_DESC		"string to FMRI"
101 #define	TOPO_METH_COMPARE_DESC		"compare two FMRIs"
102 #define	TOPO_METH_PROP_GET_DESC		"get properties for FMRI"
103 #define	TOPO_METH_PGRP_GET_DESC		"get property group for FMRI"
104 #define	TOPO_METH_PROP_SET_DESC		"set properties for FMRI"
105 #define	TOPO_METH_FACILITY_DESC		"get facility for FMRI"
106 #define	TOPO_METH_OCCUPIED_DESC		"get occupant status"
107 
108 #define	TOPO_METH_COMPARE_RET		"compare-return"
109 #define	TOPO_METH_OCCUPIED_RET		"occupied-return"
110 
111 #define	TOPO_METH_FMRI_ARG_NAME		"child-name"
112 #define	TOPO_METH_FMRI_ARG_INST		"child-inst"
113 #define	TOPO_METH_FMRI_ARG_NVL		"args"
114 #define	TOPO_METH_FMRI_ARG_PARENT	"parent-fmri"
115 #define	TOPO_METH_FMRI_ARG_AUTH		"auth"
116 #define	TOPO_METH_FMRI_ARG_PART		"part"
117 #define	TOPO_METH_FMRI_ARG_REV		"rev"
118 #define	TOPO_METH_FMRI_ARG_SER		"serial"
119 #define	TOPO_METH_FMRI_ARG_HCS		"hc-specific"
120 #define	TOPO_METH_FMRI_ARG_FMRI		"fmri"
121 #define	TOPO_METH_FMRI_ARG_SUBFMRI	"sub-fmri"
122 #define	TOPO_METH_FMRI_ARG_NV1		"nv1"
123 #define	TOPO_METH_FMRI_ARG_NV2		"nv2"
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _TOPO_METHOD_H */
130