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