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*3247Sgjelinek * Common Development and Distribution License (the "License"). 6*3247Sgjelinek * 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*3247Sgjelinek * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * NOTE 280Sstevel@tonic-gate * 290Sstevel@tonic-gate * The following contents of this file are private to the 300Sstevel@tonic-gate * implementation of the Solaris system and are subject to change at 310Sstevel@tonic-gate * any time without notice. Applications using these interfaces may 320Sstevel@tonic-gate * fail to run on future releases. 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifndef _POOL_H 360Sstevel@tonic-gate #define _POOL_H 370Sstevel@tonic-gate 380Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 390Sstevel@tonic-gate 400Sstevel@tonic-gate #include <sys/procset.h> 410Sstevel@tonic-gate #include <sys/types.h> 420Sstevel@tonic-gate #include <sys/pool.h> 430Sstevel@tonic-gate 440Sstevel@tonic-gate #ifdef __cplusplus 450Sstevel@tonic-gate extern "C" { 460Sstevel@tonic-gate #endif 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * Library versioning support (c.f. elf_version(3e)). 500Sstevel@tonic-gate * 510Sstevel@tonic-gate * You can enquire about the version number of the library 520Sstevel@tonic-gate * by passing POOL_VER_NONE. POOL_VER_CURRENT is the current 530Sstevel@tonic-gate * (most capable) version. 540Sstevel@tonic-gate * 550Sstevel@tonic-gate * You can set the version used by the library by passing the 560Sstevel@tonic-gate * required version number. If this is not possible, the version 570Sstevel@tonic-gate * returned will be POOL_VER_NONE. 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate #define POOL_VER_CURRENT 1 600Sstevel@tonic-gate #define POOL_VER_NONE 0 610Sstevel@tonic-gate 620Sstevel@tonic-gate extern uint_t pool_version(uint_t ver); 630Sstevel@tonic-gate 640Sstevel@tonic-gate #ifndef PO_TRUE 650Sstevel@tonic-gate #define PO_TRUE 1 660Sstevel@tonic-gate #endif 670Sstevel@tonic-gate 680Sstevel@tonic-gate #ifndef PO_FALSE 690Sstevel@tonic-gate #define PO_FALSE 0 700Sstevel@tonic-gate #endif 710Sstevel@tonic-gate 720Sstevel@tonic-gate #ifndef PO_SUCCESS 730Sstevel@tonic-gate #define PO_SUCCESS 0 740Sstevel@tonic-gate #endif 750Sstevel@tonic-gate 760Sstevel@tonic-gate #ifndef PO_FAIL 770Sstevel@tonic-gate #define PO_FAIL -1 780Sstevel@tonic-gate #endif 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* Error codes */ 810Sstevel@tonic-gate #define POE_OK 0 820Sstevel@tonic-gate #define POE_BAD_PROP_TYPE 1 830Sstevel@tonic-gate #define POE_INVALID_CONF 2 840Sstevel@tonic-gate #define POE_NOTSUP 3 850Sstevel@tonic-gate #define POE_INVALID_SEARCH 4 860Sstevel@tonic-gate #define POE_BADPARAM 5 870Sstevel@tonic-gate #define POE_PUTPROP 6 880Sstevel@tonic-gate #define POE_DATASTORE 7 890Sstevel@tonic-gate #define POE_SYSTEM 8 900Sstevel@tonic-gate #define POE_ACCESS 9 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* Open Flags */ 930Sstevel@tonic-gate #define PO_RDONLY 0x0 940Sstevel@tonic-gate #define PO_RDWR 0x1 950Sstevel@tonic-gate #define PO_CREAT 0x2 960Sstevel@tonic-gate #define PO_DISCO 0x4 970Sstevel@tonic-gate #define PO_UPDATE 0x8 98*3247Sgjelinek #define PO_TEMP 0x10 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* Allocation policy */ 1010Sstevel@tonic-gate #define POA_IMPORTANCE "importance based" 1020Sstevel@tonic-gate #define POA_SURPLUS_TO_DEFAULT "surplus to default" 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* Pools updates */ 1050Sstevel@tonic-gate #define POU_SYSTEM 0x1 1060Sstevel@tonic-gate #define POU_POOL 0x2 1070Sstevel@tonic-gate #define POU_PSET 0x4 1080Sstevel@tonic-gate #define POU_CPU 0x8 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* Data Export Formats */ 1110Sstevel@tonic-gate typedef enum pool_export_format { 1120Sstevel@tonic-gate POX_NATIVE, /* Native data representation format */ 1130Sstevel@tonic-gate POX_TEXT /* Text */ 1140Sstevel@tonic-gate } pool_export_format_t; 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* Property data types */ 1170Sstevel@tonic-gate typedef enum pool_value_class { 1180Sstevel@tonic-gate POC_INVAL = -1, 1190Sstevel@tonic-gate POC_UINT, 1200Sstevel@tonic-gate POC_INT, 1210Sstevel@tonic-gate POC_DOUBLE, 1220Sstevel@tonic-gate POC_BOOL, 1230Sstevel@tonic-gate POC_STRING 1240Sstevel@tonic-gate } pool_value_class_t; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* Validation levels */ 1270Sstevel@tonic-gate typedef enum pool_valid_level { 1280Sstevel@tonic-gate POV_NONE = 0, /* No validation */ 1290Sstevel@tonic-gate POV_LOOSE, /* Loose validation */ 1300Sstevel@tonic-gate POV_STRICT, /* Strict validation */ 1310Sstevel@tonic-gate POV_RUNTIME /* Validate instantiation on current machine */ 1320Sstevel@tonic-gate } pool_valid_level_t; 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate /* conf states */ 1350Sstevel@tonic-gate typedef enum pool_conf_state { 1360Sstevel@tonic-gate POF_INVALID = -1, 1370Sstevel@tonic-gate POF_VALID, 1380Sstevel@tonic-gate POF_DESTROY 1390Sstevel@tonic-gate } pool_conf_state_t; 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* Element data values */ 1420Sstevel@tonic-gate typedef struct pool_value pool_value_t; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* Elements */ 1450Sstevel@tonic-gate typedef struct pool_elem pool_elem_t; 1460Sstevel@tonic-gate typedef struct pool pool_t; 1470Sstevel@tonic-gate typedef struct pool_resource pool_resource_t; 1480Sstevel@tonic-gate typedef struct pool_component pool_component_t; 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /* 1510Sstevel@tonic-gate * Resource management configuration 1520Sstevel@tonic-gate */ 1530Sstevel@tonic-gate typedef struct pool_conf pool_conf_t; 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate extern int pool_error(void); 1560Sstevel@tonic-gate extern const char *pool_strerror(int); 1570Sstevel@tonic-gate extern int pool_resource_type_list(const char **, uint_t *); 1580Sstevel@tonic-gate extern int pool_get_status(int *); 1590Sstevel@tonic-gate extern int pool_set_status(int); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate /* Configuration manipulation */ 1620Sstevel@tonic-gate extern pool_conf_t *pool_conf_alloc(void); 1630Sstevel@tonic-gate extern void pool_conf_free(pool_conf_t *); 1640Sstevel@tonic-gate extern pool_conf_state_t pool_conf_status(const pool_conf_t *); 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate extern int pool_conf_close(pool_conf_t *); 1670Sstevel@tonic-gate extern int pool_conf_remove(pool_conf_t *); 1680Sstevel@tonic-gate extern int pool_conf_open(pool_conf_t *, const char *, int); 1690Sstevel@tonic-gate extern int pool_conf_rollback(pool_conf_t *); 1700Sstevel@tonic-gate extern int pool_conf_commit(pool_conf_t *, int); 1710Sstevel@tonic-gate extern int pool_conf_export(const pool_conf_t *, const char *, 1720Sstevel@tonic-gate pool_export_format_t); 1730Sstevel@tonic-gate extern int pool_conf_validate(const pool_conf_t *, pool_valid_level_t); 1740Sstevel@tonic-gate extern int pool_conf_update(const pool_conf_t *, int *); 1750Sstevel@tonic-gate extern pool_t *pool_get_pool(const pool_conf_t *, const char *); 1760Sstevel@tonic-gate extern pool_t **pool_query_pools(const pool_conf_t *, uint_t *, 1770Sstevel@tonic-gate pool_value_t **); 1780Sstevel@tonic-gate extern pool_resource_t *pool_get_resource(const pool_conf_t *, const char *, 1790Sstevel@tonic-gate const char *); 1800Sstevel@tonic-gate extern pool_resource_t **pool_query_resources(const pool_conf_t *, uint_t *, 1810Sstevel@tonic-gate pool_value_t **); 1820Sstevel@tonic-gate extern pool_component_t **pool_query_components(const pool_conf_t *, uint_t *, 1830Sstevel@tonic-gate pool_value_t **); 1840Sstevel@tonic-gate extern const char *pool_conf_location(const pool_conf_t *); 1850Sstevel@tonic-gate extern char *pool_conf_info(const pool_conf_t *, int); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* Resource manipulation */ 1880Sstevel@tonic-gate extern pool_resource_t *pool_resource_create(pool_conf_t *, const char *, 1890Sstevel@tonic-gate const char *); 1900Sstevel@tonic-gate extern int pool_resource_destroy(pool_conf_t *, pool_resource_t *); 1910Sstevel@tonic-gate extern int pool_resource_transfer(pool_conf_t *, pool_resource_t *, 1920Sstevel@tonic-gate pool_resource_t *, uint64_t); 1930Sstevel@tonic-gate extern int pool_resource_xtransfer(pool_conf_t *, pool_resource_t *, 1940Sstevel@tonic-gate pool_resource_t *, pool_component_t **); 1950Sstevel@tonic-gate extern pool_component_t **pool_query_resource_components(const pool_conf_t *, 1960Sstevel@tonic-gate const pool_resource_t *, uint_t *, pool_value_t **); 1970Sstevel@tonic-gate extern char *pool_resource_info(const pool_conf_t *, const pool_resource_t *, 1980Sstevel@tonic-gate int); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate /* Pool manipulation */ 2010Sstevel@tonic-gate extern pool_t *pool_create(pool_conf_t *, const char *); 2020Sstevel@tonic-gate extern int pool_destroy(pool_conf_t *, pool_t *); 2030Sstevel@tonic-gate extern int pool_associate(pool_conf_t *, pool_t *, const pool_resource_t *); 2040Sstevel@tonic-gate extern int pool_dissociate(pool_conf_t *, pool_t *, const pool_resource_t *); 2050Sstevel@tonic-gate extern char *pool_info(const pool_conf_t *, const pool_t *, int); 2060Sstevel@tonic-gate extern pool_resource_t **pool_query_pool_resources(const pool_conf_t *, 2070Sstevel@tonic-gate const pool_t *, uint_t *, pool_value_t **); 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate /* Resource Component Manipulation */ 2100Sstevel@tonic-gate extern pool_resource_t *pool_get_owning_resource(const pool_conf_t *, 2110Sstevel@tonic-gate const pool_component_t *); 2120Sstevel@tonic-gate extern char *pool_component_info(const pool_conf_t *, const pool_component_t *, 2130Sstevel@tonic-gate int); 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate /* Property manipulation */ 2160Sstevel@tonic-gate extern pool_value_class_t pool_get_property(const pool_conf_t *, 2170Sstevel@tonic-gate const pool_elem_t *, const char *, pool_value_t *); 2180Sstevel@tonic-gate extern int pool_put_property(pool_conf_t *, pool_elem_t *, const char *, 2190Sstevel@tonic-gate const pool_value_t *); 2200Sstevel@tonic-gate extern int pool_rm_property(pool_conf_t *, pool_elem_t *, const char *); 221*3247Sgjelinek 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * Walk the associated properties of the supplied element calling the supplied 2240Sstevel@tonic-gate * function for each property in turn. There is no implied order in the walk. 2250Sstevel@tonic-gate * The arg parameter allows caller-specific data to be passed to the call. 2260Sstevel@tonic-gate */ 2270Sstevel@tonic-gate extern int pool_walk_properties(pool_conf_t *, pool_elem_t *, void *, 2280Sstevel@tonic-gate int (*)(pool_conf_t *, pool_elem_t *, const char *, pool_value_t *, 2290Sstevel@tonic-gate void *)); 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate /* Get the underlying element */ 2320Sstevel@tonic-gate extern pool_elem_t *pool_conf_to_elem(const pool_conf_t *); 2330Sstevel@tonic-gate extern pool_elem_t *pool_to_elem(const pool_conf_t *, const pool_t *); 2340Sstevel@tonic-gate extern pool_elem_t *pool_resource_to_elem(const pool_conf_t *, 2350Sstevel@tonic-gate const pool_resource_t *); 2360Sstevel@tonic-gate extern pool_elem_t *pool_component_to_elem(const pool_conf_t *, 2370Sstevel@tonic-gate const pool_component_t *); 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /* Pool Property Value Manipulation */ 2400Sstevel@tonic-gate /* Get/Set Pool Property Values and Type */ 2410Sstevel@tonic-gate extern int pool_value_get_uint64(const pool_value_t *, uint64_t *); 2420Sstevel@tonic-gate extern int pool_value_get_int64(const pool_value_t *, int64_t *); 2430Sstevel@tonic-gate extern int pool_value_get_double(const pool_value_t *, double *); 2440Sstevel@tonic-gate extern int pool_value_get_bool(const pool_value_t *, uchar_t *); 2450Sstevel@tonic-gate extern int pool_value_get_string(const pool_value_t *, const char **); 2460Sstevel@tonic-gate extern pool_value_class_t pool_value_get_type(const pool_value_t *); 2470Sstevel@tonic-gate extern void pool_value_set_uint64(pool_value_t *, uint64_t); 2480Sstevel@tonic-gate extern void pool_value_set_int64(pool_value_t *, int64_t); 2490Sstevel@tonic-gate extern void pool_value_set_double(pool_value_t *, double); 2500Sstevel@tonic-gate extern void pool_value_set_bool(pool_value_t *, uchar_t); 2510Sstevel@tonic-gate extern int pool_value_set_string(pool_value_t *, const char *); 2520Sstevel@tonic-gate extern const char *pool_value_get_name(const pool_value_t *); 2530Sstevel@tonic-gate extern int pool_value_set_name(pool_value_t *, const char *); 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate /* Pool Property Value Creation/Destruction */ 2560Sstevel@tonic-gate extern pool_value_t *pool_value_alloc(void); 2570Sstevel@tonic-gate extern void pool_value_free(pool_value_t *); 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate /* Default pool data store locations */ 2600Sstevel@tonic-gate extern const char *pool_static_location(void); 2610Sstevel@tonic-gate extern const char *pool_dynamic_location(void); 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* Binding */ 2640Sstevel@tonic-gate extern int pool_set_binding(const char *, idtype_t, id_t); 2650Sstevel@tonic-gate extern char *pool_get_binding(pid_t); 2660Sstevel@tonic-gate extern char *pool_get_resource_binding(const char *, pid_t); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate /* Walking */ 2690Sstevel@tonic-gate extern int pool_walk_pools(pool_conf_t *, void *, 2700Sstevel@tonic-gate int (*)(pool_conf_t *, pool_t *, void *)); 2710Sstevel@tonic-gate extern int pool_walk_resources(pool_conf_t *, pool_t *, void *, 2720Sstevel@tonic-gate int (*)(pool_conf_t *, pool_resource_t *, void *)); 2730Sstevel@tonic-gate extern int pool_walk_components(pool_conf_t *, pool_resource_t *, void *, 2740Sstevel@tonic-gate int (*)(pool_conf_t *, pool_component_t *, void *)); 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate #ifdef __cplusplus 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate #endif 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate #endif /* _POOL_H */ 281