xref: /titanic_51/usr/src/lib/librcm/librcm.h (revision 0c44d0008f52b6a42b9c01d3b344661217520a68)
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 2006 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 
61 /*
62  * RCM return values
63  */
64 #define	RCM_SUCCESS		0
65 #define	RCM_FAILURE		-1
66 #define	RCM_CONFLICT		-2
67 
68 /*
69  * RCM resource states
70  */
71 #define	RCM_STATE_UNKNOWN		0
72 #define	RCM_STATE_ONLINE		1
73 #define	RCM_STATE_ONLINING		2
74 #define	RCM_STATE_OFFLINE_FAIL		3
75 #define	RCM_STATE_OFFLINING		4
76 #define	RCM_STATE_OFFLINE		5
77 #define	RCM_STATE_REMOVING		6
78 #define	RCM_STATE_RESUMING		10
79 #define	RCM_STATE_SUSPEND_FAIL		11
80 #define	RCM_STATE_SUSPENDING		12
81 #define	RCM_STATE_SUSPEND		13
82 #define	RCM_STATE_REMOVE		14	/* private to rcm_daemon */
83 #define	RCM_STATE_OFFLINE_QUERYING	15
84 #define	RCM_STATE_OFFLINE_QUERY_FAIL	16
85 #define	RCM_STATE_OFFLINE_QUERY		17
86 #define	RCM_STATE_SUSPEND_QUERYING	18
87 #define	RCM_STATE_SUSPEND_QUERY_FAIL	19
88 #define	RCM_STATE_SUSPEND_QUERY		20
89 
90 /*
91  * RCM event attr and properties
92  */
93 #define	RCM_RSRCNAME		"rcm.rsrcname"
94 #define	RCM_CLIENT_NAME		"rcm.client_name"
95 #define	RCM_CLIENT_EXPORTS	"rcm.client_exports"
96 
97 /* Resource name to register for new network resources */
98 #define	RCM_RESOURCE_NETWORK_NEW	"SUNW_event/resource/new/network"
99 
100 /* name-value pair definitions for rcm_notify_event() */
101 #define	RCM_NV_DRIVER_NAME	"driver_name"
102 #define	RCM_NV_INSTANCE		"instance"
103 #define	RCM_NV_NODE_NAME	"node_name"
104 #define	RCM_NV_DEVFS_PATH	"devfs_path"
105 #define	RCM_NV_MINOR_DATA	"minor_data"
106 #define	RCM_NV_MINOR_TYPE	"minor_type"
107 #define	RCM_NV_MINOR_NAME	"minor_name"
108 #define	RCM_NV_MINOR_NODE_TYPE	"minor_node_type"
109 
110 /*
111  * rcm handles
112  */
113 typedef struct rcm_handle rcm_handle_t;
114 typedef struct rcm_info rcm_info_t;
115 typedef rcm_info_t rcm_info_tuple_t;
116 
117 /*
118  * Interface definitions
119  */
120 int rcm_alloc_handle(char *, uint_t, void *, rcm_handle_t **);
121 int rcm_free_handle(rcm_handle_t *);
122 int rcm_get_info(rcm_handle_t *, char *, uint_t, rcm_info_t **);
123 int rcm_get_info_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
124 void rcm_free_info(rcm_info_t *);
125 int rcm_append_info(rcm_info_t **, rcm_info_t *);
126 rcm_info_tuple_t *rcm_info_next(rcm_info_t *, rcm_info_tuple_t *);
127 const char *rcm_info_rsrc(rcm_info_tuple_t *);
128 const char *rcm_info_info(rcm_info_tuple_t *);
129 const char *rcm_info_error(rcm_info_tuple_t *);
130 const char *rcm_info_modname(rcm_info_tuple_t *);
131 pid_t rcm_info_pid(rcm_info_tuple_t *);
132 int rcm_info_state(rcm_info_tuple_t *);
133 int rcm_info_seqnum(rcm_info_tuple_t *);
134 nvlist_t *rcm_info_properties(rcm_info_tuple_t *);
135 
136 int rcm_request_offline(rcm_handle_t *, char *, uint_t, rcm_info_t **);
137 int rcm_request_offline_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
138 int rcm_notify_online(rcm_handle_t *, char *, uint_t, rcm_info_t **);
139 int rcm_notify_online_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
140 int rcm_notify_remove(rcm_handle_t *, char *, uint_t, rcm_info_t **);
141 int rcm_notify_remove_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
142 int rcm_request_suspend(rcm_handle_t *, char *, uint_t, timespec_t *,
143 	rcm_info_t **);
144 int rcm_request_suspend_list(rcm_handle_t *, char **, uint_t, timespec_t *,
145 	rcm_info_t **);
146 int rcm_notify_resume(rcm_handle_t *, char *, uint_t, rcm_info_t **);
147 int rcm_notify_resume_list(rcm_handle_t *, char **, uint_t, rcm_info_t **);
148 int rcm_notify_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
149 	rcm_info_t **);
150 int rcm_request_capacity_change(rcm_handle_t *, char *, uint_t, nvlist_t *,
151 	rcm_info_t **);
152 int rcm_notify_event(rcm_handle_t *, char *, uint_t, nvlist_t *, rcm_info_t **);
153 
154 int rcm_register_event(rcm_handle_t *, char *, uint_t, rcm_info_t **);
155 int rcm_register_capacity(rcm_handle_t *, char *, uint_t, rcm_info_t **);
156 int rcm_register_interest(rcm_handle_t *, char *, uint_t, rcm_info_t **);
157 int rcm_unregister_event(rcm_handle_t *, char *, uint_t);
158 int rcm_unregister_capacity(rcm_handle_t *, char *, uint_t);
159 int rcm_unregister_interest(rcm_handle_t *, char *, uint_t);
160 
161 int rcm_get_rsrcstate(rcm_handle_t *, char *, int *);
162 int rcm_exec_cmd(char *);
163 const char *rcm_get_client_name(rcm_handle_t *);
164 
165 #ifdef	__cplusplus
166 }
167 #endif
168 
169 #endif	/* _LIBRCM_H */
170