10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*11878SVenu.Iyer@Sun.COM * Common Development and Distribution License (the "License"). 6*11878SVenu.Iyer@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*11878SVenu.Iyer@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_POOL_H 270Sstevel@tonic-gate #define _SYS_POOL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/time.h> 310Sstevel@tonic-gate #include <sys/nvpair.h> 320Sstevel@tonic-gate #include <sys/procset.h> 330Sstevel@tonic-gate #include <sys/list.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate #define POOL_DEFAULT 0 /* default pool's ID */ 400Sstevel@tonic-gate #define POOL_MAXID 999999 /* maximum possible pool ID */ 41*11878SVenu.Iyer@Sun.COM #define POOL_INVALID -1 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* pools states */ 440Sstevel@tonic-gate #define POOL_DISABLED 0 /* pools enabled */ 450Sstevel@tonic-gate #define POOL_ENABLED 1 /* pools disabled */ 460Sstevel@tonic-gate 470Sstevel@tonic-gate #ifdef _KERNEL 480Sstevel@tonic-gate 490Sstevel@tonic-gate struct pool_pset; 500Sstevel@tonic-gate 510Sstevel@tonic-gate typedef struct pool { 520Sstevel@tonic-gate poolid_t pool_id; /* pool ID */ 530Sstevel@tonic-gate uint32_t pool_ref; /* # of procs in this pool */ 540Sstevel@tonic-gate list_node_t pool_link; /* links to next/prev pools */ 550Sstevel@tonic-gate nvlist_t *pool_props; /* pool properties */ 560Sstevel@tonic-gate struct pool_pset *pool_pset; /* pool's pset */ 570Sstevel@tonic-gate } pool_t; 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * Flags for pool_do_bind 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate #define POOL_BIND_PSET 0x00000001 630Sstevel@tonic-gate #define POOL_BIND_ALL POOL_BIND_PSET 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Result codes for pool_get_class() 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate #define POOL_CLASS_UNSET -1 /* no scheduling class set */ 690Sstevel@tonic-gate #define POOL_CLASS_INVAL -2 /* class is invalid */ 700Sstevel@tonic-gate 710Sstevel@tonic-gate extern int pool_count; /* current number of pools */ 720Sstevel@tonic-gate extern pool_t *pool_default; /* default pool pointer */ 730Sstevel@tonic-gate extern int pool_state; /* pools state -- enabled/disabled */ 740Sstevel@tonic-gate extern void *pool_buf; /* last state snapshot */ 750Sstevel@tonic-gate extern size_t pool_bufsz; /* size of pool_buf */ 760Sstevel@tonic-gate 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * Lookup routines 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate extern pool_t *pool_lookup_pool_by_id(poolid_t); 810Sstevel@tonic-gate extern pool_t *pool_lookup_pool_by_name(char *); 82*11878SVenu.Iyer@Sun.COM extern pool_t *pool_lookup_pool_by_pset(int); 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * Configuration routines 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate extern void pool_init(void); 880Sstevel@tonic-gate extern int pool_status(int); 890Sstevel@tonic-gate extern int pool_create(int, int, id_t *); 900Sstevel@tonic-gate extern int pool_destroy(int, int, id_t); 910Sstevel@tonic-gate extern int pool_transfer(int, id_t, id_t, uint64_t); 920Sstevel@tonic-gate extern int pool_assoc(poolid_t, int, id_t); 930Sstevel@tonic-gate extern int pool_dissoc(poolid_t, int); 940Sstevel@tonic-gate extern int pool_bind(poolid_t, idtype_t, id_t); 950Sstevel@tonic-gate extern id_t pool_get_class(pool_t *); 960Sstevel@tonic-gate extern int pool_do_bind(pool_t *, idtype_t, id_t, int); 970Sstevel@tonic-gate extern int pool_query_binding(idtype_t, id_t, id_t *); 980Sstevel@tonic-gate extern int pool_xtransfer(int, id_t, id_t, uint_t, id_t *); 990Sstevel@tonic-gate extern int pool_pack_conf(void *, size_t, size_t *); 1000Sstevel@tonic-gate extern int pool_propput(int, int, id_t, nvpair_t *); 1010Sstevel@tonic-gate extern int pool_proprm(int, int, id_t, char *); 1020Sstevel@tonic-gate extern int pool_propget(char *, int, int, id_t, nvlist_t **); 1030Sstevel@tonic-gate extern int pool_commit(int); 104*11878SVenu.Iyer@Sun.COM extern void pool_get_name(pool_t *, char **); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate /* 1070Sstevel@tonic-gate * Synchronization routines 1080Sstevel@tonic-gate */ 1090Sstevel@tonic-gate extern void pool_lock(void); 1100Sstevel@tonic-gate extern int pool_lock_intr(void); 1110Sstevel@tonic-gate extern int pool_lock_held(void); 1120Sstevel@tonic-gate extern void pool_unlock(void); 1130Sstevel@tonic-gate extern void pool_barrier_enter(void); 1140Sstevel@tonic-gate extern void pool_barrier_exit(void); 1150Sstevel@tonic-gate 116*11878SVenu.Iyer@Sun.COM typedef enum { 117*11878SVenu.Iyer@Sun.COM POOL_E_ENABLE, 118*11878SVenu.Iyer@Sun.COM POOL_E_DISABLE, 119*11878SVenu.Iyer@Sun.COM POOL_E_CHANGE, 120*11878SVenu.Iyer@Sun.COM } pool_event_t; 121*11878SVenu.Iyer@Sun.COM 122*11878SVenu.Iyer@Sun.COM typedef void pool_event_cb_func_t(pool_event_t, poolid_t, void *); 123*11878SVenu.Iyer@Sun.COM 124*11878SVenu.Iyer@Sun.COM typedef struct pool_event_cb { 125*11878SVenu.Iyer@Sun.COM pool_event_cb_func_t *pec_func; 126*11878SVenu.Iyer@Sun.COM void *pec_arg; 127*11878SVenu.Iyer@Sun.COM list_node_t pec_list; 128*11878SVenu.Iyer@Sun.COM } pool_event_cb_t; 129*11878SVenu.Iyer@Sun.COM 130*11878SVenu.Iyer@Sun.COM /* 131*11878SVenu.Iyer@Sun.COM * Routines used to register interest in changes in cpu pools. 132*11878SVenu.Iyer@Sun.COM */ 133*11878SVenu.Iyer@Sun.COM extern void pool_event_cb_register(pool_event_cb_t *); 134*11878SVenu.Iyer@Sun.COM extern void pool_event_cb_unregister(pool_event_cb_t *); 1350Sstevel@tonic-gate #endif /* _KERNEL */ 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate #ifdef __cplusplus 1380Sstevel@tonic-gate } 1390Sstevel@tonic-gate #endif 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #endif /* _SYS_POOL_H */ 142