17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0dc2366fSVenugopal Iyer * Common Development and Distribution License (the "License"). 6*0dc2366fSVenugopal Iyer * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*0dc2366fSVenugopal Iyer * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_POOL_H 277c478bd9Sstevel@tonic-gate #define _SYS_POOL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/time.h> 317c478bd9Sstevel@tonic-gate #include <sys/nvpair.h> 327c478bd9Sstevel@tonic-gate #include <sys/procset.h> 337c478bd9Sstevel@tonic-gate #include <sys/list.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define POOL_DEFAULT 0 /* default pool's ID */ 407c478bd9Sstevel@tonic-gate #define POOL_MAXID 999999 /* maximum possible pool ID */ 41*0dc2366fSVenugopal Iyer #define POOL_INVALID -1 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* pools states */ 447c478bd9Sstevel@tonic-gate #define POOL_DISABLED 0 /* pools enabled */ 457c478bd9Sstevel@tonic-gate #define POOL_ENABLED 1 /* pools disabled */ 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #ifdef _KERNEL 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate struct pool_pset; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate typedef struct pool { 527c478bd9Sstevel@tonic-gate poolid_t pool_id; /* pool ID */ 537c478bd9Sstevel@tonic-gate uint32_t pool_ref; /* # of procs in this pool */ 547c478bd9Sstevel@tonic-gate list_node_t pool_link; /* links to next/prev pools */ 557c478bd9Sstevel@tonic-gate nvlist_t *pool_props; /* pool properties */ 567c478bd9Sstevel@tonic-gate struct pool_pset *pool_pset; /* pool's pset */ 577c478bd9Sstevel@tonic-gate } pool_t; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Flags for pool_do_bind 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate #define POOL_BIND_PSET 0x00000001 637c478bd9Sstevel@tonic-gate #define POOL_BIND_ALL POOL_BIND_PSET 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Result codes for pool_get_class() 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #define POOL_CLASS_UNSET -1 /* no scheduling class set */ 697c478bd9Sstevel@tonic-gate #define POOL_CLASS_INVAL -2 /* class is invalid */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate extern int pool_count; /* current number of pools */ 727c478bd9Sstevel@tonic-gate extern pool_t *pool_default; /* default pool pointer */ 737c478bd9Sstevel@tonic-gate extern int pool_state; /* pools state -- enabled/disabled */ 747c478bd9Sstevel@tonic-gate extern void *pool_buf; /* last state snapshot */ 757c478bd9Sstevel@tonic-gate extern size_t pool_bufsz; /* size of pool_buf */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Lookup routines 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate extern pool_t *pool_lookup_pool_by_id(poolid_t); 817c478bd9Sstevel@tonic-gate extern pool_t *pool_lookup_pool_by_name(char *); 82*0dc2366fSVenugopal Iyer extern pool_t *pool_lookup_pool_by_pset(int); 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Configuration routines 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate extern void pool_init(void); 887c478bd9Sstevel@tonic-gate extern int pool_status(int); 897c478bd9Sstevel@tonic-gate extern int pool_create(int, int, id_t *); 907c478bd9Sstevel@tonic-gate extern int pool_destroy(int, int, id_t); 917c478bd9Sstevel@tonic-gate extern int pool_transfer(int, id_t, id_t, uint64_t); 927c478bd9Sstevel@tonic-gate extern int pool_assoc(poolid_t, int, id_t); 937c478bd9Sstevel@tonic-gate extern int pool_dissoc(poolid_t, int); 947c478bd9Sstevel@tonic-gate extern int pool_bind(poolid_t, idtype_t, id_t); 957c478bd9Sstevel@tonic-gate extern id_t pool_get_class(pool_t *); 967c478bd9Sstevel@tonic-gate extern int pool_do_bind(pool_t *, idtype_t, id_t, int); 977c478bd9Sstevel@tonic-gate extern int pool_query_binding(idtype_t, id_t, id_t *); 987c478bd9Sstevel@tonic-gate extern int pool_xtransfer(int, id_t, id_t, uint_t, id_t *); 997c478bd9Sstevel@tonic-gate extern int pool_pack_conf(void *, size_t, size_t *); 1007c478bd9Sstevel@tonic-gate extern int pool_propput(int, int, id_t, nvpair_t *); 1017c478bd9Sstevel@tonic-gate extern int pool_proprm(int, int, id_t, char *); 1027c478bd9Sstevel@tonic-gate extern int pool_propget(char *, int, int, id_t, nvlist_t **); 1037c478bd9Sstevel@tonic-gate extern int pool_commit(int); 104*0dc2366fSVenugopal Iyer extern void pool_get_name(pool_t *, char **); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Synchronization routines 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate extern void pool_lock(void); 1107c478bd9Sstevel@tonic-gate extern int pool_lock_intr(void); 1117c478bd9Sstevel@tonic-gate extern int pool_lock_held(void); 1127c478bd9Sstevel@tonic-gate extern void pool_unlock(void); 1137c478bd9Sstevel@tonic-gate extern void pool_barrier_enter(void); 1147c478bd9Sstevel@tonic-gate extern void pool_barrier_exit(void); 1157c478bd9Sstevel@tonic-gate 116*0dc2366fSVenugopal Iyer typedef enum { 117*0dc2366fSVenugopal Iyer POOL_E_ENABLE, 118*0dc2366fSVenugopal Iyer POOL_E_DISABLE, 119*0dc2366fSVenugopal Iyer POOL_E_CHANGE, 120*0dc2366fSVenugopal Iyer } pool_event_t; 121*0dc2366fSVenugopal Iyer 122*0dc2366fSVenugopal Iyer typedef void pool_event_cb_func_t(pool_event_t, poolid_t, void *); 123*0dc2366fSVenugopal Iyer 124*0dc2366fSVenugopal Iyer typedef struct pool_event_cb { 125*0dc2366fSVenugopal Iyer pool_event_cb_func_t *pec_func; 126*0dc2366fSVenugopal Iyer void *pec_arg; 127*0dc2366fSVenugopal Iyer list_node_t pec_list; 128*0dc2366fSVenugopal Iyer } pool_event_cb_t; 129*0dc2366fSVenugopal Iyer 130*0dc2366fSVenugopal Iyer /* 131*0dc2366fSVenugopal Iyer * Routines used to register interest in changes in cpu pools. 132*0dc2366fSVenugopal Iyer */ 133*0dc2366fSVenugopal Iyer extern void pool_event_cb_register(pool_event_cb_t *); 134*0dc2366fSVenugopal Iyer extern void pool_event_cb_unregister(pool_event_cb_t *); 1357c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1387c478bd9Sstevel@tonic-gate } 1397c478bd9Sstevel@tonic-gate #endif 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #endif /* _SYS_POOL_H */ 142