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*0209230bSgjelinek * Common Development and Distribution License (the "License"). 6*0209230bSgjelinek * 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*0209230bSgjelinek * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * NOTE 287c478bd9Sstevel@tonic-gate * 297c478bd9Sstevel@tonic-gate * The following contents of this file are private to the 307c478bd9Sstevel@tonic-gate * implementation of the Solaris system and are subject to change at 317c478bd9Sstevel@tonic-gate * any time without notice. Applications using these interfaces may 327c478bd9Sstevel@tonic-gate * fail to run on future releases. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifndef _POOL_H 367c478bd9Sstevel@tonic-gate #define _POOL_H 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <sys/procset.h> 417c478bd9Sstevel@tonic-gate #include <sys/types.h> 427c478bd9Sstevel@tonic-gate #include <sys/pool.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 457c478bd9Sstevel@tonic-gate extern "C" { 467c478bd9Sstevel@tonic-gate #endif 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Library versioning support (c.f. elf_version(3e)). 507c478bd9Sstevel@tonic-gate * 517c478bd9Sstevel@tonic-gate * You can enquire about the version number of the library 527c478bd9Sstevel@tonic-gate * by passing POOL_VER_NONE. POOL_VER_CURRENT is the current 537c478bd9Sstevel@tonic-gate * (most capable) version. 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * You can set the version used by the library by passing the 567c478bd9Sstevel@tonic-gate * required version number. If this is not possible, the version 577c478bd9Sstevel@tonic-gate * returned will be POOL_VER_NONE. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate #define POOL_VER_CURRENT 1 607c478bd9Sstevel@tonic-gate #define POOL_VER_NONE 0 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate extern uint_t pool_version(uint_t ver); 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #ifndef PO_TRUE 657c478bd9Sstevel@tonic-gate #define PO_TRUE 1 667c478bd9Sstevel@tonic-gate #endif 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #ifndef PO_FALSE 697c478bd9Sstevel@tonic-gate #define PO_FALSE 0 707c478bd9Sstevel@tonic-gate #endif 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #ifndef PO_SUCCESS 737c478bd9Sstevel@tonic-gate #define PO_SUCCESS 0 747c478bd9Sstevel@tonic-gate #endif 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate #ifndef PO_FAIL 777c478bd9Sstevel@tonic-gate #define PO_FAIL -1 787c478bd9Sstevel@tonic-gate #endif 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* Error codes */ 817c478bd9Sstevel@tonic-gate #define POE_OK 0 827c478bd9Sstevel@tonic-gate #define POE_BAD_PROP_TYPE 1 837c478bd9Sstevel@tonic-gate #define POE_INVALID_CONF 2 847c478bd9Sstevel@tonic-gate #define POE_NOTSUP 3 857c478bd9Sstevel@tonic-gate #define POE_INVALID_SEARCH 4 867c478bd9Sstevel@tonic-gate #define POE_BADPARAM 5 877c478bd9Sstevel@tonic-gate #define POE_PUTPROP 6 887c478bd9Sstevel@tonic-gate #define POE_DATASTORE 7 897c478bd9Sstevel@tonic-gate #define POE_SYSTEM 8 907c478bd9Sstevel@tonic-gate #define POE_ACCESS 9 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* Open Flags */ 937c478bd9Sstevel@tonic-gate #define PO_RDONLY 0x0 947c478bd9Sstevel@tonic-gate #define PO_RDWR 0x1 957c478bd9Sstevel@tonic-gate #define PO_CREAT 0x2 967c478bd9Sstevel@tonic-gate #define PO_DISCO 0x4 977c478bd9Sstevel@tonic-gate #define PO_UPDATE 0x8 98*0209230bSgjelinek #define PO_TEMP 0x10 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* Allocation policy */ 1017c478bd9Sstevel@tonic-gate #define POA_IMPORTANCE "importance based" 1027c478bd9Sstevel@tonic-gate #define POA_SURPLUS_TO_DEFAULT "surplus to default" 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* Pools updates */ 1057c478bd9Sstevel@tonic-gate #define POU_SYSTEM 0x1 1067c478bd9Sstevel@tonic-gate #define POU_POOL 0x2 1077c478bd9Sstevel@tonic-gate #define POU_PSET 0x4 1087c478bd9Sstevel@tonic-gate #define POU_CPU 0x8 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* Data Export Formats */ 1117c478bd9Sstevel@tonic-gate typedef enum pool_export_format { 1127c478bd9Sstevel@tonic-gate POX_NATIVE, /* Native data representation format */ 1137c478bd9Sstevel@tonic-gate POX_TEXT /* Text */ 1147c478bd9Sstevel@tonic-gate } pool_export_format_t; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* Property data types */ 1177c478bd9Sstevel@tonic-gate typedef enum pool_value_class { 1187c478bd9Sstevel@tonic-gate POC_INVAL = -1, 1197c478bd9Sstevel@tonic-gate POC_UINT, 1207c478bd9Sstevel@tonic-gate POC_INT, 1217c478bd9Sstevel@tonic-gate POC_DOUBLE, 1227c478bd9Sstevel@tonic-gate POC_BOOL, 1237c478bd9Sstevel@tonic-gate POC_STRING 1247c478bd9Sstevel@tonic-gate } pool_value_class_t; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* Validation levels */ 1277c478bd9Sstevel@tonic-gate typedef enum pool_valid_level { 1287c478bd9Sstevel@tonic-gate POV_NONE = 0, /* No validation */ 1297c478bd9Sstevel@tonic-gate POV_LOOSE, /* Loose validation */ 1307c478bd9Sstevel@tonic-gate POV_STRICT, /* Strict validation */ 1317c478bd9Sstevel@tonic-gate POV_RUNTIME /* Validate instantiation on current machine */ 1327c478bd9Sstevel@tonic-gate } pool_valid_level_t; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* conf states */ 1357c478bd9Sstevel@tonic-gate typedef enum pool_conf_state { 1367c478bd9Sstevel@tonic-gate POF_INVALID = -1, 1377c478bd9Sstevel@tonic-gate POF_VALID, 1387c478bd9Sstevel@tonic-gate POF_DESTROY 1397c478bd9Sstevel@tonic-gate } pool_conf_state_t; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* Element data values */ 1427c478bd9Sstevel@tonic-gate typedef struct pool_value pool_value_t; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* Elements */ 1457c478bd9Sstevel@tonic-gate typedef struct pool_elem pool_elem_t; 1467c478bd9Sstevel@tonic-gate typedef struct pool pool_t; 1477c478bd9Sstevel@tonic-gate typedef struct pool_resource pool_resource_t; 1487c478bd9Sstevel@tonic-gate typedef struct pool_component pool_component_t; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * Resource management configuration 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate typedef struct pool_conf pool_conf_t; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate extern int pool_error(void); 1567c478bd9Sstevel@tonic-gate extern const char *pool_strerror(int); 1577c478bd9Sstevel@tonic-gate extern int pool_resource_type_list(const char **, uint_t *); 1587c478bd9Sstevel@tonic-gate extern int pool_get_status(int *); 1597c478bd9Sstevel@tonic-gate extern int pool_set_status(int); 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* Configuration manipulation */ 1627c478bd9Sstevel@tonic-gate extern pool_conf_t *pool_conf_alloc(void); 1637c478bd9Sstevel@tonic-gate extern void pool_conf_free(pool_conf_t *); 1647c478bd9Sstevel@tonic-gate extern pool_conf_state_t pool_conf_status(const pool_conf_t *); 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate extern int pool_conf_close(pool_conf_t *); 1677c478bd9Sstevel@tonic-gate extern int pool_conf_remove(pool_conf_t *); 1687c478bd9Sstevel@tonic-gate extern int pool_conf_open(pool_conf_t *, const char *, int); 1697c478bd9Sstevel@tonic-gate extern int pool_conf_rollback(pool_conf_t *); 1707c478bd9Sstevel@tonic-gate extern int pool_conf_commit(pool_conf_t *, int); 1717c478bd9Sstevel@tonic-gate extern int pool_conf_export(const pool_conf_t *, const char *, 1727c478bd9Sstevel@tonic-gate pool_export_format_t); 1737c478bd9Sstevel@tonic-gate extern int pool_conf_validate(const pool_conf_t *, pool_valid_level_t); 1747c478bd9Sstevel@tonic-gate extern int pool_conf_update(const pool_conf_t *, int *); 1757c478bd9Sstevel@tonic-gate extern pool_t *pool_get_pool(const pool_conf_t *, const char *); 1767c478bd9Sstevel@tonic-gate extern pool_t **pool_query_pools(const pool_conf_t *, uint_t *, 1777c478bd9Sstevel@tonic-gate pool_value_t **); 1787c478bd9Sstevel@tonic-gate extern pool_resource_t *pool_get_resource(const pool_conf_t *, const char *, 1797c478bd9Sstevel@tonic-gate const char *); 1807c478bd9Sstevel@tonic-gate extern pool_resource_t **pool_query_resources(const pool_conf_t *, uint_t *, 1817c478bd9Sstevel@tonic-gate pool_value_t **); 1827c478bd9Sstevel@tonic-gate extern pool_component_t **pool_query_components(const pool_conf_t *, uint_t *, 1837c478bd9Sstevel@tonic-gate pool_value_t **); 1847c478bd9Sstevel@tonic-gate extern const char *pool_conf_location(const pool_conf_t *); 1857c478bd9Sstevel@tonic-gate extern char *pool_conf_info(const pool_conf_t *, int); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* Resource manipulation */ 1887c478bd9Sstevel@tonic-gate extern pool_resource_t *pool_resource_create(pool_conf_t *, const char *, 1897c478bd9Sstevel@tonic-gate const char *); 1907c478bd9Sstevel@tonic-gate extern int pool_resource_destroy(pool_conf_t *, pool_resource_t *); 1917c478bd9Sstevel@tonic-gate extern int pool_resource_transfer(pool_conf_t *, pool_resource_t *, 1927c478bd9Sstevel@tonic-gate pool_resource_t *, uint64_t); 1937c478bd9Sstevel@tonic-gate extern int pool_resource_xtransfer(pool_conf_t *, pool_resource_t *, 1947c478bd9Sstevel@tonic-gate pool_resource_t *, pool_component_t **); 1957c478bd9Sstevel@tonic-gate extern pool_component_t **pool_query_resource_components(const pool_conf_t *, 1967c478bd9Sstevel@tonic-gate const pool_resource_t *, uint_t *, pool_value_t **); 1977c478bd9Sstevel@tonic-gate extern char *pool_resource_info(const pool_conf_t *, const pool_resource_t *, 1987c478bd9Sstevel@tonic-gate int); 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* Pool manipulation */ 2017c478bd9Sstevel@tonic-gate extern pool_t *pool_create(pool_conf_t *, const char *); 2027c478bd9Sstevel@tonic-gate extern int pool_destroy(pool_conf_t *, pool_t *); 2037c478bd9Sstevel@tonic-gate extern int pool_associate(pool_conf_t *, pool_t *, const pool_resource_t *); 2047c478bd9Sstevel@tonic-gate extern int pool_dissociate(pool_conf_t *, pool_t *, const pool_resource_t *); 2057c478bd9Sstevel@tonic-gate extern char *pool_info(const pool_conf_t *, const pool_t *, int); 2067c478bd9Sstevel@tonic-gate extern pool_resource_t **pool_query_pool_resources(const pool_conf_t *, 2077c478bd9Sstevel@tonic-gate const pool_t *, uint_t *, pool_value_t **); 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* Resource Component Manipulation */ 2107c478bd9Sstevel@tonic-gate extern pool_resource_t *pool_get_owning_resource(const pool_conf_t *, 2117c478bd9Sstevel@tonic-gate const pool_component_t *); 2127c478bd9Sstevel@tonic-gate extern char *pool_component_info(const pool_conf_t *, const pool_component_t *, 2137c478bd9Sstevel@tonic-gate int); 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate /* Property manipulation */ 2167c478bd9Sstevel@tonic-gate extern pool_value_class_t pool_get_property(const pool_conf_t *, 2177c478bd9Sstevel@tonic-gate const pool_elem_t *, const char *, pool_value_t *); 2187c478bd9Sstevel@tonic-gate extern int pool_put_property(pool_conf_t *, pool_elem_t *, const char *, 2197c478bd9Sstevel@tonic-gate const pool_value_t *); 2207c478bd9Sstevel@tonic-gate extern int pool_rm_property(pool_conf_t *, pool_elem_t *, const char *); 221*0209230bSgjelinek 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * Walk the associated properties of the supplied element calling the supplied 2247c478bd9Sstevel@tonic-gate * function for each property in turn. There is no implied order in the walk. 2257c478bd9Sstevel@tonic-gate * The arg parameter allows caller-specific data to be passed to the call. 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate extern int pool_walk_properties(pool_conf_t *, pool_elem_t *, void *, 2287c478bd9Sstevel@tonic-gate int (*)(pool_conf_t *, pool_elem_t *, const char *, pool_value_t *, 2297c478bd9Sstevel@tonic-gate void *)); 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* Get the underlying element */ 2327c478bd9Sstevel@tonic-gate extern pool_elem_t *pool_conf_to_elem(const pool_conf_t *); 2337c478bd9Sstevel@tonic-gate extern pool_elem_t *pool_to_elem(const pool_conf_t *, const pool_t *); 2347c478bd9Sstevel@tonic-gate extern pool_elem_t *pool_resource_to_elem(const pool_conf_t *, 2357c478bd9Sstevel@tonic-gate const pool_resource_t *); 2367c478bd9Sstevel@tonic-gate extern pool_elem_t *pool_component_to_elem(const pool_conf_t *, 2377c478bd9Sstevel@tonic-gate const pool_component_t *); 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate /* Pool Property Value Manipulation */ 2407c478bd9Sstevel@tonic-gate /* Get/Set Pool Property Values and Type */ 2417c478bd9Sstevel@tonic-gate extern int pool_value_get_uint64(const pool_value_t *, uint64_t *); 2427c478bd9Sstevel@tonic-gate extern int pool_value_get_int64(const pool_value_t *, int64_t *); 2437c478bd9Sstevel@tonic-gate extern int pool_value_get_double(const pool_value_t *, double *); 2447c478bd9Sstevel@tonic-gate extern int pool_value_get_bool(const pool_value_t *, uchar_t *); 2457c478bd9Sstevel@tonic-gate extern int pool_value_get_string(const pool_value_t *, const char **); 2467c478bd9Sstevel@tonic-gate extern pool_value_class_t pool_value_get_type(const pool_value_t *); 2477c478bd9Sstevel@tonic-gate extern void pool_value_set_uint64(pool_value_t *, uint64_t); 2487c478bd9Sstevel@tonic-gate extern void pool_value_set_int64(pool_value_t *, int64_t); 2497c478bd9Sstevel@tonic-gate extern void pool_value_set_double(pool_value_t *, double); 2507c478bd9Sstevel@tonic-gate extern void pool_value_set_bool(pool_value_t *, uchar_t); 2517c478bd9Sstevel@tonic-gate extern int pool_value_set_string(pool_value_t *, const char *); 2527c478bd9Sstevel@tonic-gate extern const char *pool_value_get_name(const pool_value_t *); 2537c478bd9Sstevel@tonic-gate extern int pool_value_set_name(pool_value_t *, const char *); 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate /* Pool Property Value Creation/Destruction */ 2567c478bd9Sstevel@tonic-gate extern pool_value_t *pool_value_alloc(void); 2577c478bd9Sstevel@tonic-gate extern void pool_value_free(pool_value_t *); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* Default pool data store locations */ 2607c478bd9Sstevel@tonic-gate extern const char *pool_static_location(void); 2617c478bd9Sstevel@tonic-gate extern const char *pool_dynamic_location(void); 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate /* Binding */ 2647c478bd9Sstevel@tonic-gate extern int pool_set_binding(const char *, idtype_t, id_t); 2657c478bd9Sstevel@tonic-gate extern char *pool_get_binding(pid_t); 2667c478bd9Sstevel@tonic-gate extern char *pool_get_resource_binding(const char *, pid_t); 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* Walking */ 2697c478bd9Sstevel@tonic-gate extern int pool_walk_pools(pool_conf_t *, void *, 2707c478bd9Sstevel@tonic-gate int (*)(pool_conf_t *, pool_t *, void *)); 2717c478bd9Sstevel@tonic-gate extern int pool_walk_resources(pool_conf_t *, pool_t *, void *, 2727c478bd9Sstevel@tonic-gate int (*)(pool_conf_t *, pool_resource_t *, void *)); 2737c478bd9Sstevel@tonic-gate extern int pool_walk_components(pool_conf_t *, pool_resource_t *, void *, 2747c478bd9Sstevel@tonic-gate int (*)(pool_conf_t *, pool_component_t *, void *)); 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate #endif 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate #endif /* _POOL_H */ 281