xref: /titanic_44/usr/src/uts/common/sys/pool.h (revision 1cb6af97c6f66f456d4f726ef056e1ebc0f73305)
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_H
28 #define	_SYS_POOL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/time.h>
34 #include <sys/nvpair.h>
35 #include <sys/procset.h>
36 #include <sys/list.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	POOL_DEFAULT		0		/* default pool's ID */
43 #define	POOL_MAXID		999999		/* maximum possible pool ID */
44 
45 /* pools states */
46 #define	POOL_DISABLED		0		/* pools enabled */
47 #define	POOL_ENABLED		1		/* pools disabled */
48 
49 #ifdef	_KERNEL
50 
51 struct pool_pset;
52 
53 typedef struct pool {
54 	poolid_t		pool_id;	/* pool ID */
55 	uint32_t		pool_ref;	/* # of procs in this pool */
56 	list_node_t		pool_link;	/* links to next/prev pools */
57 	nvlist_t		*pool_props;	/* pool properties */
58 	struct pool_pset	*pool_pset;	/* pool's pset */
59 } pool_t;
60 
61 /*
62  * Flags for pool_do_bind
63  */
64 #define	POOL_BIND_PSET	0x00000001
65 #define	POOL_BIND_ALL	POOL_BIND_PSET
66 
67 /*
68  * Result codes for pool_get_class()
69  */
70 #define	POOL_CLASS_UNSET	-1		/* no scheduling class set */
71 #define	POOL_CLASS_INVAL	-2		/* class is invalid */
72 
73 extern int	pool_count;	/* current number of pools */
74 extern pool_t	*pool_default;	/* default pool pointer */
75 extern int	pool_state;	/* pools state -- enabled/disabled */
76 extern void	*pool_buf;	/* last state snapshot */
77 extern size_t	pool_bufsz;	/* size of pool_buf */
78 
79 /*
80  * Lookup routines
81  */
82 extern pool_t	*pool_lookup_pool_by_id(poolid_t);
83 extern pool_t	*pool_lookup_pool_by_name(char *);
84 
85 /*
86  * Configuration routines
87  */
88 extern void 	pool_init(void);
89 extern int	pool_status(int);
90 extern int	pool_create(int, int, id_t *);
91 extern int	pool_destroy(int, int, id_t);
92 extern int	pool_transfer(int, id_t, id_t, uint64_t);
93 extern int	pool_assoc(poolid_t, int, id_t);
94 extern int	pool_dissoc(poolid_t, int);
95 extern int	pool_bind(poolid_t, idtype_t, id_t);
96 extern id_t	pool_get_class(pool_t *);
97 extern int	pool_do_bind(pool_t *, idtype_t, id_t, int);
98 extern int	pool_query_binding(idtype_t, id_t, id_t *);
99 extern int	pool_xtransfer(int, id_t, id_t, uint_t, id_t *);
100 extern int	pool_pack_conf(void *, size_t, size_t *);
101 extern int	pool_propput(int, int, id_t, nvpair_t *);
102 extern int	pool_proprm(int, int, id_t, char *);
103 extern int	pool_propget(char *, int, int, id_t, nvlist_t **);
104 extern int	pool_commit(int);
105 
106 /*
107  * Synchronization routines
108  */
109 extern void	pool_lock(void);
110 extern int	pool_lock_intr(void);
111 extern int	pool_lock_held(void);
112 extern void	pool_unlock(void);
113 extern void	pool_barrier_enter(void);
114 extern void	pool_barrier_exit(void);
115 
116 #endif	/* _KERNEL */
117 
118 #ifdef	__cplusplus
119 }
120 #endif
121 
122 #endif	/* _SYS_POOL_H */
123