xref: /titanic_44/usr/src/lib/librcm/librcm.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_LIBRCM_H
28 #define	_LIBRCM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <libnvpair.h>
33 #include <sys/types.h>
34 #include <sys/processor.h>
35 #include <sys/pset.h>
36 #include <sys/time_impl.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Flags for rcm requests
44  */
45 #define	RCM_INCLUDE_SUBTREE	0x0001
46 #define	RCM_INCLUDE_DEPENDENT	0x0002
47 #define	RCM_QUERY		0x0004
48 #define	RCM_FORCE		0x0008
49 #define	RCM_FILESYS		0x0010	/* private to filesys module */
50 #define	RCM_NOPID		0x0020
51 #define	RCM_DR_OPERATION	0x0040
52 #define	RCM_MOD_INFO		0x0080	/* private */
53 #define	RCM_CAPACITY_ADD	0x0100
54 #define	RCM_CAPACITY_DELETE	0x0200
55 #define	RCM_QUERY_CANCEL	0x0400	/* private */
56 #define	RCM_SCOPE		0x0800
57 #define	RCM_REGISTER_DR		0x1000	/* private */
58 #define	RCM_REGISTER_EVENT	0x2000	/* private */
59 #define	RCM_REGISTER_CAPACITY	0x4000	/* private */
60 #define	RCM_SUSPENDED		0x8000	/* private */
61 
62 /*
63  * RCM return values
64  */
65 #define	RCM_SUCCESS		0
66 #define	RCM_FAILURE		-1
67 #define	RCM_CONFLICT		-2
68 
69 /*
70  * RCM resource states
71  */
72 #define	RCM_STATE_UNKNOWN		0
73 #define	RCM_STATE_ONLINE		1
74 #define	RCM_STATE_ONLINING		2
75 #define	RCM_STATE_OFFLINE_FAIL		3
76 #define	RCM_STATE_OFFLINING		4
77 #define	RCM_STATE_OFFLINE		5
78 #define	RCM_STATE_REMOVING		6
79 #define	RCM_STATE_RESUMING		10
80 #define	RCM_STATE_SUSPEND_FAIL		11
81 #define	RCM_STATE_SUSPENDING		12
82 #define	RCM_STATE_SUSPEND		13
83 #define	RCM_STATE_REMOVE		14	/* private to rcm_daemon */
84 #define	RCM_STATE_OFFLINE_QUERYING	15
85 #define	RCM_STATE_OFFLINE_QUERY_FAIL	16
86 #define	RCM_STATE_OFFLINE_QUERY		17
87 #define	RCM_STATE_SUSPEND_QUERYING	18
88 #define	RCM_STATE_SUSPEND_QUERY_FAIL	19
89 #define	RCM_STATE_SUSPEND_QUERY		20
90 
91 /*
92  * RCM event attr and properties
93  */
94 #define	RCM_RSRCNAME		"rcm.rsrcname"
95 #define	RCM_CLIENT_NAME		"rcm.client_name"
96 #define	RCM_CLIENT_EXPORTS	"rcm.client_exports"
97 
98 /* Resource name to register for new network resources */
99 #define	RCM_RESOURCE_NETWORK_NEW	"SUNW_event/resource/new/network"
100 /* Resource name to register for new MAC resources */
101 #define	RCM_RESOURCE_MAC_NEW		"SUNW_event/resource/new/mac"
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