xref: /illumos-gate/usr/src/uts/common/sys/pool.h (revision e5803b76927480e8f9b67b22201c484ccf4c2bcf)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_POOL_H
27 #define	_SYS_POOL_H
28 
29 #include <sys/types.h>
30 #include <sys/time.h>
31 #include <sys/nvpair.h>
32 #include <sys/procset.h>
33 #include <sys/list.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	POOL_DEFAULT		0		/* default pool's ID */
40 #define	POOL_MAXID		999999		/* maximum possible pool ID */
41 #define	POOL_INVALID		-1
42 
43 /* pools states */
44 #define	POOL_DISABLED		0		/* pools enabled */
45 #define	POOL_ENABLED		1		/* pools disabled */
46 
47 #ifdef	_KERNEL
48 
49 struct pool_pset;
50 
51 typedef struct pool {
52 	poolid_t		pool_id;	/* pool ID */
53 	uint32_t		pool_ref;	/* # of procs in this pool */
54 	list_node_t		pool_link;	/* links to next/prev pools */
55 	nvlist_t		*pool_props;	/* pool properties */
56 	struct pool_pset	*pool_pset;	/* pool's pset */
57 } pool_t;
58 
59 /*
60  * Flags for pool_do_bind
61  */
62 #define	POOL_BIND_PSET	0x00000001
63 #define	POOL_BIND_ALL	POOL_BIND_PSET
64 
65 /*
66  * Result codes for pool_get_class()
67  */
68 #define	POOL_CLASS_UNSET	-1		/* no scheduling class set */
69 #define	POOL_CLASS_INVAL	-2		/* class is invalid */
70 
71 extern int	pool_count;	/* current number of pools */
72 extern pool_t	*pool_default;	/* default pool pointer */
73 extern int	pool_state;	/* pools state -- enabled/disabled */
74 extern void	*pool_buf;	/* last state snapshot */
75 extern size_t	pool_bufsz;	/* size of pool_buf */
76 
77 /*
78  * Lookup routines
79  */
80 extern pool_t	*pool_lookup_pool_by_id(poolid_t);
81 extern pool_t	*pool_lookup_pool_by_name(char *);
82 extern pool_t	*pool_lookup_pool_by_pset(int);
83 
84 /*
85  * Configuration routines
86  */
87 extern void 	pool_init(void);
88 extern int	pool_status(int);
89 extern int	pool_create(int, int, id_t *);
90 extern int	pool_destroy(int, int, id_t);
91 extern int	pool_transfer(int, id_t, id_t, uint64_t);
92 extern int	pool_assoc(poolid_t, int, id_t);
93 extern int	pool_dissoc(poolid_t, int);
94 extern int	pool_bind(poolid_t, idtype_t, id_t);
95 extern id_t	pool_get_class(pool_t *);
96 extern int	pool_do_bind(pool_t *, idtype_t, id_t, int);
97 extern int	pool_query_binding(idtype_t, id_t, id_t *);
98 extern int	pool_xtransfer(int, id_t, id_t, uint_t, id_t *);
99 extern int	pool_pack_conf(void *, size_t, size_t *);
100 extern int	pool_propput(int, int, id_t, nvpair_t *);
101 extern int	pool_proprm(int, int, id_t, char *);
102 extern int	pool_propget(char *, int, int, id_t, nvlist_t **);
103 extern int	pool_commit(int);
104 extern void	pool_get_name(pool_t *, char **);
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 typedef enum {
117 	POOL_E_ENABLE,
118 	POOL_E_DISABLE,
119 	POOL_E_CHANGE,
120 } pool_event_t;
121 
122 typedef void pool_event_cb_func_t(pool_event_t, poolid_t,  void *);
123 
124 typedef struct pool_event_cb {
125 	pool_event_cb_func_t	*pec_func;
126 	void			*pec_arg;
127 	list_node_t		pec_list;
128 } pool_event_cb_t;
129 
130 /*
131  * Routines used to register interest in changes in cpu pools.
132  */
133 extern void pool_event_cb_register(pool_event_cb_t *);
134 extern void pool_event_cb_unregister(pool_event_cb_t *);
135 #endif	/* _KERNEL */
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_POOL_H */
142