xref: /illumos-gate/usr/src/lib/librcm/librcm.h (revision dd4eeefd)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBRCM_H
27 #define	_LIBRCM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <libnvpair.h>
32 #include <sys/types.h>
33 #include <sys/processor.h>
34 #include <sys/pset.h>
35 #include <sys/time_impl.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Flags for rcm requests
43  */
44 #define	RCM_INCLUDE_SUBTREE	0x0001
45 #define	RCM_INCLUDE_DEPENDENT	0x0002
46 #define	RCM_QUERY		0x0004
47 #define	RCM_FORCE		0x0008
48 #define	RCM_FILESYS		0x0010	/* private to filesys module */
49 #define	RCM_NOPID		0x0020
50 #define	RCM_DR_OPERATION	0x0040
51 #define	RCM_MOD_INFO		0x0080	/* private */
52 #define	RCM_CAPACITY_ADD	0x0100
53 #define	RCM_CAPACITY_DELETE	0x0200
54 #define	RCM_QUERY_CANCEL	0x0400	/* private */
55 #define	RCM_SCOPE		0x0800
56 #define	RCM_REGISTER_DR		0x1000	/* private */
57 #define	RCM_REGISTER_EVENT	0x2000	/* private */
58 #define	RCM_REGISTER_CAPACITY	0x4000	/* private */
59 #define	RCM_SUSPENDED		0x8000	/* private */
60 #define	RCM_RETIRE_REQUEST	0x10000
61 #define	RCM_RETIRE_NOTIFY	0x20000
62 
63 /*
64  * RCM return values
65  */
66 #define	RCM_SUCCESS		0
67 #define	RCM_FAILURE		-1
68 #define	RCM_CONFLICT		-2
69 #define	RCM_NO_CONSTRAINT	-3
70 
71 /*
72  * RCM resource states
73  */
74 #define	RCM_STATE_UNKNOWN		0
75 #define	RCM_STATE_ONLINE		1
76 #define	RCM_STATE_ONLINING		2
77 #define	RCM_STATE_OFFLINE_FAIL		3
78 #define	RCM_STATE_OFFLINING		4
79 #define	RCM_STATE_OFFLINE		5
80 #define	RCM_STATE_REMOVING		6
81 #define	RCM_STATE_RESUMING		10
82 #define	RCM_STATE_SUSPEND_FAIL		11
83 #define	RCM_STATE_SUSPENDING		12
84 #define	RCM_STATE_SUSPEND		13
85 #define	RCM_STATE_REMOVE		14	/* private to rcm_daemon */
86 #define	RCM_STATE_OFFLINE_QUERYING	15
87 #define	RCM_STATE_OFFLINE_QUERY_FAIL	16
88 #define	RCM_STATE_OFFLINE_QUERY		17
89 #define	RCM_STATE_SUSPEND_QUERYING	18
90 #define	RCM_STATE_SUSPEND_QUERY_FAIL	19
91 #define	RCM_STATE_SUSPEND_QUERY		20
92 
93 /*
94  * RCM event attr and properties
95  */
96 #define	RCM_RSRCNAME		"rcm.rsrcname"
97 #define	RCM_CLIENT_NAME		"rcm.client_name"
98 #define	RCM_CLIENT_EXPORTS	"rcm.client_exports"
99 
100 /* Resource name to register for new network resources */
101 #define	RCM_RESOURCE_NETWORK_NEW	"SUNW_event/resource/new/network"
102 
103 /* name-value pair definitions for rcm_notify_event() */
104 #define	RCM_NV_DRIVER_NAME	"driver_name"
105 #define	RCM_NV_INSTANCE		"instance"
106 #define	RCM_NV_NODE_NAME	"node_name"
107 #define	RCM_NV_DEVFS_PATH	"devfs_path"
108 #define	RCM_NV_MINOR_DATA	"minor_data"
109 #define	RCM_NV_MINOR_TYPE	"minor_type"
110 #define	RCM_NV_MINOR_NAME	"minor_name"
111 #define	RCM_NV_MINOR_NODE_TYPE	"minor_node_type"
112 
113 /*
114  * rcm handles
115  */
116 typedef struct rcm_handle rcm_handle_t;
117 typedef struct rcm_info rcm_info_t;
118 typedef rcm_info_t rcm_info_tuple_t;
119 
120 /*
121  * Interface definitions
122  */
123 int rcm_alloc_handle(char *, uint_t, void *, rcm_handle_t **);
124 int rcm_free_handle(rcm_handle_t *);
125 int rcm_get_info(rcm_handle_t *, char *, uint_t, rcm_info_t **);
126 int rcm_get_info_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
127 void rcm_free_info(rcm_info_t *);
128 int rcm_append_info(rcm_info_t **, rcm_info_t *);
129 rcm_info_tuple_t *rcm_info_next(rcm_info_t *, rcm_info_tuple_t *);
130 const char *rcm_info_rsrc(rcm_info_tuple_t *);
131 const char *rcm_info_info(rcm_info_tuple_t *);
132 const char *rcm_info_error(rcm_info_tuple_t *);
133 const char *rcm_info_modname(rcm_info_tuple_t *);
134 pid_t rcm_info_pid(rcm_info_tuple_t *);
135 int rcm_info_state(rcm_info_tuple_t *);
136 int rcm_info_seqnum(rcm_info_tuple_t *);
137 nvlist_t *rcm_info_properties(rcm_info_tuple_t *);
138 
139 int rcm_request_offline(rcm_handle_t *, char *, uint_t, rcm_info_t **);
140 int rcm_request_offline_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
141 int rcm_notify_online(rcm_handle_t *, char *, uint_t, rcm_info_t **);
142 int rcm_notify_online_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
143 int rcm_notify_remove(rcm_handle_t *, char *, uint_t, rcm_info_t **);
144 int rcm_notify_remove_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
145 int rcm_request_suspend(rcm_handle_t *, char *, uint_t, timespec_t *,
146 	rcm_info_t **);
147 int rcm_request_suspend_list(rcm_handle_t *, char **, uint_t, timespec_t *,
148 	rcm_info_t **);
149 int rcm_notify_resume(rcm_handle_t *, char *, uint_t, rcm_info_t **);
150 int rcm_notify_resume_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
151 int rcm_notify_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
152 	rcm_info_t **);
153 int rcm_request_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
154 	rcm_info_t **);
155 int rcm_notify_event(rcm_handle_t *, char *, uint_t, nvlist_t *, rcm_info_t **);
156 
157 int rcm_register_event(rcm_handle_t *, char *, uint_t, rcm_info_t **);
158 int rcm_register_capacity(rcm_handle_t *, char *, uint_t, rcm_info_t **);
159 int rcm_register_interest(rcm_handle_t *, char *, uint_t, rcm_info_t **);
160 int rcm_unregister_event(rcm_handle_t *, char *, uint_t);
161 int rcm_unregister_capacity(rcm_handle_t *, char *, uint_t);
162 int rcm_unregister_interest(rcm_handle_t *, char *, uint_t);
163 
164 int rcm_get_rsrcstate(rcm_handle_t *, char *, int *);
165 int rcm_exec_cmd(char *);
166 const char *rcm_get_client_name(rcm_handle_t *);
167 
168 #ifdef	__cplusplus
169 }
170 #endif
171 
172 #endif	/* _LIBRCM_H */
173