xref: /illumos-gate/usr/src/uts/common/sys/pool_impl.h (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_POOL_IMPL_H
28 #define	_SYS_POOL_IMPL_H
29 
30 #include <sys/types.h>
31 #include <sys/cpupart.h>
32 #include <sys/exacct_catalog.h>
33 #include <sys/nvpair.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Pools driver ioctl interfaces
41  */
42 #define	POOL_STATUS	0
43 #define	POOL_STATUSQ	1
44 #define	POOL_CREATE	2
45 #define	POOL_DESTROY	3
46 #define	POOL_QUERY	4
47 #define	POOL_ASSOC	5
48 #define	POOL_DISSOC	6
49 #define	POOL_TRANSFER	7
50 #define	POOL_XTRANSFER	8
51 #define	POOL_PROPGET	9
52 #define	POOL_PROPPUT	10
53 #define	POOL_PROPRM	11
54 #define	POOL_BIND	12
55 #define	POOL_BINDQ	13
56 #define	POOL_COMMIT	14
57 
58 /*
59  * Pools-related exacct catalog IDs
60  */
61 #define	EXD_GROUP_SYSTEM	0x000000
62 #define	EXD_SYSTEM_PROP		0x000001
63 #define	EXD_SYSTEM_TSTAMP	0x000002
64 
65 #define	EXD_GROUP_POOL		0x000100
66 #define	EXD_POOL_POOLID		0x000101
67 #define	EXD_POOL_PSETID		0x000102
68 #define	EXD_POOL_PROP		0x000104
69 #define	EXD_POOL_TSTAMP		0x000105
70 
71 #define	EXD_GROUP_PSET		0x000200
72 #define	EXD_PSET_PSETID		0x000201
73 #define	EXD_PSET_PROP		0x000202
74 #define	EXD_PSET_TSTAMP		0x000203
75 
76 #define	EXD_GROUP_CPU		0x000400
77 #define	EXD_CPU_CPUID		0x000401
78 #define	EXD_CPU_PROP		0x000402
79 #define	EXD_CPU_TSTAMP		0x000403
80 
81 /*
82  * Element Types
83  */
84 typedef enum pool_elem_class {
85 	PEC_INVALID = 0,	/* invalid class, for error reporting */
86 	PEC_SYSTEM,		/* a system */
87 	PEC_POOL,		/* a pool */
88 	PEC_RES_COMP,		/* a set */
89 	PEC_RES_AGG,		/* a set */
90 	PEC_COMP		/* a resource component */
91 } pool_elem_class_t;
92 
93 typedef enum pool_resource_elem_class {
94 	PREC_INVALID = 0,
95 	PREC_PSET		/* processor set */
96 } pool_resource_elem_class_t;
97 
98 typedef enum pool_component_elem_class {
99 	PCEC_INVALID = 0,
100 	PCEC_CPU		/* CPU */
101 } pool_component_elem_class_t;
102 
103 /*
104  * Constants used by devpool.
105  */
106 #define	POOL_IDLIST_SIZE	1024
107 #define	POOL_PROPNAME_SIZE	8192
108 #define	POOL_PROPBUF_SIZE	65535
109 
110 typedef struct pool_status {
111 	int				ps_io_state;
112 } pool_status_t;
113 
114 typedef struct pool_create {
115 	id_t				pc_i_id;
116 	int				pc_o_type;
117 	int				pc_o_sub_type;
118 } pool_create_t;
119 
120 typedef struct pool_destroy {
121 	int				pd_o_type;
122 	int				pd_o_sub_type;
123 	id_t				pd_o_id;
124 } pool_destroy_t;
125 
126 typedef struct pool_query {
127 	size_t				pq_io_bufsize;
128 	void				*pq_io_buf;
129 } pool_query_t;
130 
131 #ifdef	_SYSCALL32
132 typedef struct pool_query32 {
133 	size32_t			pq_io_bufsize;
134 	caddr32_t			pq_io_buf;
135 } pool_query32_t;
136 #endif	/* _SYSCALL32 */
137 
138 typedef struct pool_assoc {
139 	poolid_t			pa_o_pool_id;
140 	pool_resource_elem_class_t	pa_o_id_type;
141 	id_t				pa_o_res_id;
142 } pool_assoc_t;
143 
144 typedef struct pool_dissoc {
145 	poolid_t			pd_o_pool_id;
146 	pool_resource_elem_class_t	pd_o_id_type;
147 } pool_dissoc_t;
148 
149 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
150 #pragma pack(4)
151 #endif
152 
153 typedef struct pool_transfer {
154 	pool_resource_elem_class_t	pt_o_id_type;
155 	id_t				pt_o_src_id;
156 	id_t				pt_o_tgt_id;
157 	uint64_t			pt_o_qty;
158 } pool_transfer_t;
159 
160 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
161 #pragma pack()
162 #endif
163 
164 typedef struct pool_xtransfer {
165 	pool_resource_elem_class_t	px_o_id_type;
166 	id_t				px_o_src_id;
167 	id_t				px_o_tgt_id;
168 	uint_t				px_o_complist_size;
169 	id_t				*px_o_comp_list;
170 } pool_xtransfer_t;
171 
172 #ifdef	_SYSCALL32
173 typedef struct pool_xtransfer32 {
174 	pool_resource_elem_class_t	px_o_id_type;
175 	id_t				px_o_src_id;
176 	id_t				px_o_tgt_id;
177 	uint_t				px_o_complist_size;
178 	caddr32_t			px_o_comp_list;
179 } pool_xtransfer32_t;
180 #endif	/* _SYSCALL32 */
181 
182 typedef struct pool_propget {
183 	size_t				pp_i_bufsize;
184 	char				*pp_i_buf;
185 	pool_elem_class_t		pp_o_id_type;
186 	pool_resource_elem_class_t	pp_o_id_subtype;
187 	id_t				pp_o_id;
188 	uint_t				pp_o_prop_name_size;
189 	char				*pp_o_prop_name;
190 } pool_propget_t;
191 
192 #ifdef	_SYSCALL32
193 typedef	struct pool_propget32 {
194 	size32_t			pp_i_bufsize;
195 	caddr32_t			pp_i_buf;
196 	pool_elem_class_t		pp_o_id_type;
197 	pool_resource_elem_class_t	pp_o_id_subtype;
198 	id_t				pp_o_id;
199 	uint_t				pp_o_prop_name_size;
200 	caddr32_t			pp_o_prop_name;
201 } pool_propget32_t;
202 #endif	/* _SYSCALL32 */
203 
204 typedef struct pool_propgetall {
205 	size_t				pp_i_proplist_size;
206 	char				*pp_i_prop_list;
207 	pool_elem_class_t		pp_o_id_type;
208 	pool_resource_elem_class_t	pp_o_id_sub_type;
209 	id_t				pp_o_id;
210 } pool_propgetall_t;
211 
212 #ifdef	_SYSCALL32
213 typedef struct pool_propgetall32 {
214 	size32_t			pp_i_proplist_size;
215 	caddr32_t			pp_i_prop_list;
216 	pool_elem_class_t		pp_o_id_type;
217 	pool_resource_elem_class_t	pp_o_id_sub_type;
218 	id_t				pp_o_id;
219 } pool_propgetall32_t;
220 #endif	/* _SYSCALL32 */
221 
222 typedef struct pool_propput {
223 	pool_elem_class_t		pp_o_id_type;
224 	pool_resource_elem_class_t	pp_o_id_sub_type;
225 	id_t				pp_o_id;
226 	size_t				pp_o_bufsize;
227 	char				*pp_o_buf;
228 } pool_propput_t;
229 
230 #ifdef	_SYSCALL32
231 typedef struct pool_propput32 {
232 	pool_elem_class_t		pp_o_id_type;
233 	pool_resource_elem_class_t	pp_o_id_sub_type;
234 	id_t				pp_o_id;
235 	size32_t			pp_o_bufsize;
236 	caddr32_t			pp_o_buf;
237 } pool_propput32_t;
238 #endif	/* _SYSCALL32 */
239 
240 typedef struct pool_proprm {
241 	pool_elem_class_t		pp_o_id_type;
242 	pool_resource_elem_class_t	pp_o_id_sub_type;
243 	id_t				pp_o_id;
244 	size_t				pp_o_prop_name_size;
245 	char				*pp_o_prop_name;
246 } pool_proprm_t;
247 
248 #ifdef	_SYSCALL32
249 typedef struct pool_proprm32 {
250 	pool_elem_class_t		pp_o_id_type;
251 	pool_resource_elem_class_t	pp_o_id_sub_type;
252 	id_t				pp_o_id;
253 	size32_t			pp_o_prop_name_size;
254 	caddr32_t			pp_o_prop_name;
255 } pool_proprm32_t;
256 #endif	/* _SYSCALL32 */
257 
258 typedef struct pool_bind {
259 	idtype_t			pb_o_id_type;
260 	id_t				pb_o_pool_id;
261 	id_t				pb_o_id;
262 } pool_bind_t;
263 
264 typedef struct pool_bindq {
265 	idtype_t			pb_o_id_type;
266 	poolid_t			pb_i_id;
267 	id_t				pb_o_id;
268 } pool_bindq_t;
269 
270 /*
271  * Values for pp_type below
272  */
273 #define	PP_READ		0x0001
274 #define	PP_WRITE	0x0002
275 #define	PP_RDWR		0x0003
276 #define	PP_OPTIONAL	0x0004
277 #define	PP_STORED	0x0008
278 #define	PP_INIT		0x0010
279 #define	PP_HIDDEN	0x0020
280 
281 #ifdef	_KERNEL
282 
283 /*
284  * For special properties
285  */
286 typedef struct pool_property {
287 	char		*pp_name;	/* name of the property */
288 	data_type_t	pp_type;	/* type of the property */
289 	int		pp_perm;	/* permissions */
290 } pool_property_t;
291 
292 extern int pool_propput_common(nvlist_t *, nvpair_t *, pool_property_t *);
293 extern int pool_proprm_common(nvlist_t *, char *, pool_property_t *);
294 
295 #endif	/* _KERNEL */
296 
297 #ifdef	__cplusplus
298 }
299 #endif
300 
301 #endif	/* _SYS_POOL_IMPL_H */
302