/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72Q src/bos/kernel/sys/corral.h 1.29.3.11 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2005,2019 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* @(#)34 1.29.3.11 src/bos/kernel/sys/corral.h, syscorral, bos72Q, q2019_13A4 2/6/19 00:42:27 */ #ifndef _CORRAL_H #define _CORRAL_H /* User space view of corrals */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* DEFINES */ #define CLIM_RSET_NAME_SIZE 2*(RSET_NAME_SIZE+1) /* struct corral c_version */ #define CVERSION_610 1 #define CVERSION_CURRENT 2 #define CORDATA_VER_CURRENT 0 /* error flags */ #define C_SYSERR 0x00000001 /* System error */ #define C_COPYIN 0x00000002 /* Copyin error. errno from copyin */ #define C_PATH_ERR 0x00000004 /* Error in setting file path. */ #define C_RMIP 0x00000008 /* Error in removing old IP addresses. */ #define C_ADDIP_1 0x00000010 /* Address in use error adding IP addresses. */ #define C_ADDIP_2 0x00000020 /* Other error in adding IP addresses. */ #define C_RCUNLOAD 0x00000040 /* Error in unloading old resource controls. */ #define C_RCLOAD 0x00000080 /* Error in loading resource controls. */ #define C_CMDEINVAL 0x00000100 /* Invalid command passed to system call. */ #define C_CNAME_ERR 0x00000200 /* Invalid corral name (i.e. already exists). */ #define C_CHGOPTION 0x00000400 /* An option change is not allowed */ #define C_DELROUTES 0x00000800 /* Error deleting explicit routes */ #define C_CRE_ERR 0x00001000 /* Invalid CRE Level */ /* * The following defines are for DR WPAR used in bos/usr/lib/corrals .. */ #define DR_WPAR_CREATE 1 #define DR_WPAR_MODIFY 0 #define DR_WPAR_DELETE -1 /* command flags * Modifications are attempted in this order. * All requests are tried unless a C_SYSERR * occurs. Errno is set from the last failure. */ #define C_SETOPTS 0x00000001 /* Set options */ #define C_SETCNAME 0x00000002 /* Set corral name */ #define C_SETHNAME 0x00000004 /* Set corral hostname */ #define C_SETROOTPATH 0x00000008 /* Set corral root path */ #define C_SETIP 0x00000010 /* Set corral IP addresses */ #define C_SETRC 0x00000020 /* Set corral resource controls */ #define C_OROPTS 0x00000040 /* Bitwise OR in the options */ #define C_SETCRE 0x00000080 /* Set corral compatibility runtime */ /* All SET operations. Does not include bitwise OR. */ #define C_ALL (C_SETOPTS|C_SETCNAME|C_SETHNAME|C_SETROOTPATH|C_SETIP|C_SETRC) /* STRUCTURES */ /* List of vips attached to a corral */ typedef struct vip { #define vip_vip vips.vip4 #define vip_vip6 vips.vip6 union { struct ifaliasreq vip4; struct in6_aliasreq vip6; } vips; } vip_t, *vipp_t, **vippp_t; typedef struct clim { struct wlm_bounds clim_bounds[WLM_RES_NB]; /* limit info */ char clim_rset_name[CLIM_RSET_NAME_SIZE]; } clim_t, *climp_t, **climpp_t; /* Due to backward compatability issue, new fields can not be * added to corral_t. Thus cordata_t was created to house new * wpar kernel attributes. * New API, cordata_config, will be used to configure cordata_t * into kwpar_t. When adding new field in cordata_t, be sure to * add corresponding CORDATAOP_* in corralid.h */ typedef struct cordata { u_int32_t cordata_ver; union { char _c_uuid[UUID_STRMAX]; /* unique id (uuid) for WPAR */ struct { uint64_t uaddr; uint32_t usize; } _ubuf; } _cordata_buf; #define c_uuid _cordata_buf._c_uuid #define c_uaddr _cordata_buf._ubuf.uaddr #define c_usize _cordata_buf._ubuf.usize ushort c_arch; /* ACE architecture */ } cordata_t, *cordatap_t, **cordatapp_t; /* Definition of a corral: * * Note that corral system calls normally take cid_t identifiers * as a parameter and this identifier is dynamically assigned * and returned as output from the kernel (within struct corral) * during the corral_config() call. * * ckey_t is a short-hand numeric identifier provided as input within * struct corral. It is provided to the corral_config() system call * and is stored within the kernel for use on certain kernel record * reporting features where a more persistent corral identity is * needed. An example of this is that accounting records which * may be formatted long after the corral is stopped have the ckey_t * identifier embedded within them. */ /* WARNING: No new field is allowed in corral_t due to the backward * compatibility issue. */ typedef struct corral { u_int32_t c_version; ckey_t c_key; /* persistent user space ID */ cid_t c_id; /* dynamic corral identifier */ cre_t c_cre; /* compat runtime environment */ u_int32_t c_opts; /* COPTs from above */ clim_t c_lim; /* resource limits */ char c_path[MAXPATHLEN]; /* path for chroot */ char c_name[MAXCORRALNAMELEN+1]; /* corral name NULL */ /* terminated */ char c_hostname[MAXHOSTNAMELEN]; uint c_numvips; /* num of vips for corral */ vip_t c_vip[1]; /* variable array of vips */ /* CAUTION: c_vip is variable. */ } corral_t, *corralp_t, **corralpp_t; /* Static size of corral structure (not including vips) */ #define CORRAL_SIZ ((int)&(((corralp_t)0)->c_vip[0])) /* * Keeping the 610 versions of these structures for compatibility issues * from the time a system is updated to 61D but before it reboots. * To support this a 610 version of the vip and corral structures are * needed. */ /* 610 version of the vip structure */ typedef struct vip_610 { struct ifaliasreq vip_610_vip; } vip_610_t, *vipp_610_t, **vippp_610_t; /* 610 version of the corral structure */ typedef struct corral_610 { u_int32_t c_version; ckey_t c_key; /* persistent user space ID */ cid_t c_id; /* dynamic corral identifier */ u_int32_t c_opts; /* COPTs from above */ clim_t c_lim; /* resource limits */ char c_path[MAXPATHLEN]; /* path for chroot */ char c_name[MAXCORRALNAMELEN+1]; /* corral name NULL */ /* terminated */ char c_hostname[MAXHOSTNAMELEN]; uint c_numvips; /* num of vips for corral */ vip_610_t c_vip[1]; /* variable array of vips */ /* CAUTION: c_vip is variable. */ } corral_610_t, *corralp_610_t, **corralpp_610_t; /* Static size of 610 corral structure (not including vips) */ #define CORRAL_610_SIZ ((int)&(((corralp_610_t)0)->c_vip[0])) /* Structure passed for brand */ typedef struct { cid_t b_cid; uint b_type; union { #define BRAND_PID 1 /* brand_t.b_type value */ pid32_t pid; } b_val; uint b_flags; } brand_t, *brandp_t, **brandpp_t; /* corral_getinfo() operators */ #define CINITPID 1 /* Get the corral init pid */ #define CHALTED 2 /* Get the corral halt status */ #define CALIVE 3 /* Is the corral loaded in kernel? */ #define CAPPWPAR 4 /* Is this an app wpar? */ #define CCR 5 /* Should we checkpoint/restart? */ #define CRIP 6 /* Is a restart in progress? */ #define CKCSTATE 7 /* Internal state (kwpar_t.kc_state) */ #define CMOBWPAR 8 /* Is this a mobile wpar? */ #define CVERSION 9 /* Retrieve the kernel's corral version (use kcid 0) */ #define CVIPWPAR 10 /* NOVIP WPAR */ #define CUUID 11 /* WPAR UUID */ #define CARCH 12 /* Get the WPAR architecture */ #define CCOMP_VERSION 13 /* Retrieve the component data version */ #define CXWPARIPC 14 /* Can this WPAR access cross-WPAR IPCs ? */ #define MAXWDEVNAME 16 /* Device export types */ typedef enum { WDEV_TYPE_NONE, /* 0x00 - Not set */ WDEV_TYPE_PSEUDO, /* 0x01 - Pseudo-device */ WDEV_TYPE_DISK, /* 0x02 - Disk device */ WDEV_TYPE_CLONE, /* 0x03 - Clone device */ WDEV_TYPE_TAPE, /* 0x4 - tape device */ WDEV_TYPE_OPTICAL, /* 0x5 - CD-ROM/DVD-ROM */ WDEV_TYPE_ADAPTER, /* 0x6 - FC Adapter type */ WDEV_TYPE_TAPE_SUB, /* 0x7 - tape device minor types*/ WDEV_TYPE_PARENT, /* 0x8 - Parent device */ WDEV_TYPE_FC_PROTOCOL /* 0x9 - FSCSI PROTOCOL */ } wdevtype_t; /* WPAR device export options */ typedef uint wdevexportopt_t; #define WDEVEXPALLMINORS 0x1 /* device allows all minors */ /* WPAR device export structure */ typedef struct wdevexport { char name[MAXWDEVNAME + 1]; /* device name */ char vname[MAXWDEVNAME + 1]; /* virtual device name */ char parent[MAXWDEVNAME + 1]; /* parent device name */ uint rmajor; /* real mjor */ uint rminor; /* real minor */ wdevtype_t type; /* device type */ mode_t mode; /* device mode */ wdevexportopt_t flags; /* device export options */ } wdevexport_t; typedef uint wdevimptopt_t; #define WDEVIMPORTED 0x1 /* device is currently imported */ #define WDEVIMPMAJOR 0x2 /* device has major number */ /* WPAR single device import structure */ typedef struct wdevimport { char name[MAXWDEVNAME + 1]; /* device name */ char vname[MAXWDEVNAME + 1]; /* virtual device name */ char parent[MAXWDEVNAME + 1]; /* parent name */ uint vmajor; /* virtual major */ uint vminor; /* virtual minor */ wdevtype_t type; /* device type */ mode_t mode; /* device mode */ wdevimptopt_t flags; /* device import flags */ } wdevimport_t; /* * WPAR Kernel Extensions Exports */ /* Export list commands */ #define WPAR_KE_ADD 0x01 /* Add KE to list */ #define WPAR_KE_RM 0x02 /* Remove KE from list */ #define WPAR_KE_RM_ALL 0x04 /* Remove all KEs from list */ #define WPAR_KE_GEN_SIG 0x08 /* Generated and return a KE signature */ #define WPAR_KE_QRY 0x10 /* Query a KE on list */ #define WPAR_KE_QRY_ALL 0x20 /* Query all KEs */ /* Export load type */ #define KEEXPLOCAL 0x1 /* Export the KE to be local */ #define KEEXPGLOBAL 0x2 /* Export the KE to be shared */ #define SURR_GLOB_DEV 0x4 /* Export Surrogate's global dev */ #define CuWxt_KE_FLAG 0xFF #define WPAR_KEDEV_VERSION 1 /* version of wdevKEexport_t */ #define WPAR_KE_HASH_SZ 32 typedef struct wdevKEexport { char name[MAXPATHLEN+1]; /* KE name */ int version; /* version of structure */ unsigned int major; /* device major */ uchar_t hash[WPAR_KE_HASH_SZ]; /* KE hash signature */ unsigned int type; /* load type Global/Local */ } wdevKEexport_t; /***********************************/ /*WPAR Resource control information*/ /***********************************/ #define WRC_NOT_SET -1 #define WRC_VALID 0x1 #define WRC_INVALID 0x0 #define WRC_CUR_VERSION 0 /* Current count of valid resoruces in wpar_limits_t */ #define WRC_CUR_RESOURCES 4 /* Max resources that can be controlled with the wpar_limits_t structure*/ #define WRC_MAX_RESOURCES 31 /* * One bit is reserved for each of the 31 resources. If a bit is set in the * following mask it indicated that this version recognizes the corresponding * resource as valid a resource present at that index in the limits array */ #define WRC_CUR_RESOURCE_MASK 0xF /*This mask indicates which resources are measure in percentages*/ #define WRC_CUR_PCT_RESOURCE_MASK 0xF /*SemID,MsqId,ShmIds,Pinned Mem*/ #define WRC_IPC_RESOURCE_MASK 0x7 /*SemId, MqId,shmId*/ #define WRC_PIN_RESOURCE_MASK 0x8 typedef long long wrc_res_limit_t; typedef struct wpar_limits{ u_int32_t wpar_limits_version; wrc_res_limit_t res[WRC_MAX_RESOURCES]; } wpar_limits_t; typedef struct kwpar_limitinfo { int flags;/*validity flags*/ ckey_t c_key; /*persistent identifier*/ int valid_resource_mask; /* Indicates which resources from the limits aqrray are valid in this instance*/ wrc_res_limit_t res_limits[WRC_CUR_RESOURCES];/*current limit*/ wrc_res_limit_t pct_limits[WRC_CUR_RESOURCES];/*percentage limit*/ wrc_res_limit_t res_usage[WRC_CUR_RESOURCES]; /*current usage*/ } kwpar_limitinfo_t; extern struct kwpar_limitinfo *wpar_limitinfo[]; #define CFG_NO_KER_MG 0x2 #define CFG_KER_MG 0x1 #define CFG_KER_ERR -1 #define WSET_MAJOR 0x01 #define WCHK_MAJOR 0x02 #define WUNSET_MAJOR 0x04 #define WLST_MAJOR 0x40 #define WSET_MINORS 0x08 #define WGET_MINORS 0x10 #define WUNSET_DEVNO 0x20 #define WCFG_ON 0x1 #define WCFG_OFF 0x2 #define CFG_SET 0x100 #define CFG_UNSET 0x200 #define CFG_QUERY 0x400 #define CFG_MASK (CFG_SET | CFG_UNSET | CFG_QUERY) #define EC_MINOR "ec_minor" #define EC_MIN_SZ 16 #define EC_MINORS "ecminors" #define WPAR_MAJOR_START 512 /* Majors structures */ typedef struct wio_major { char devinst[16]; int major; } wio_major_t; /* ****************************************************************** * Minors structures * Used for genminor * Used for reldevno (start_minor holds the minor to be removed * *****************************************************************/ typedef struct wio_minor { char ec[16]; /* Eye-catcher */ char devname[16]; /* Dev name in WPAR */ int major; /* Major number */ int preferred; /* preferrred minor */ int numMinors; /* Num. of min to alloc.*/ int inc_btwn_minors; /* inc between minors */ int inc_btwn_grp; /* length of alloc. */ int start_minor; /* start of alloc. min. */ } wio_minor_t; /* Minors list from werm to wparkexp ... */ #define MIN_BITMAP_SZ 32 typedef struct wio_minors { char ec[8]; /* Eye-catcher */ cid_t cid; /* WPAR ID */ char devname[16]; /* Dev name in WPAR */ int major; /* real major number */ int start; /* First minor */ int numMinors; /* number of minors */ int minbitmap[MIN_BITMAP_SZ]; /* minors list */ } wio_minors_t; /* System Calls */ /* The second parameter to corral_config() is a bitmask of CFLAG_* values (see * corralid.h) */ int corral_config(corralp_t, uint); /* The second parameter to corral_modify is a value/result uint. * On entry it should be set with values indicating which kernel fields * the caller wants to modify. See the C_SETXXX defines above. * On exit corral_modify returns the parameter with error flags * (see the error flag definitions above) indicating which modifications * failed and why. If no errors occurred then the parameter is set to zero. */ int corral_modify(corralp_t, uint*); int corral_delete(cid_t); cid_t corral_getcid(void); cid_t wpar_getcid(void); ckey_t corral_getckey(void); ckey_t wpar_getckey(void); int corral_getpids(cid_t, pid32_t*); int corral_query(cid_t, corralp_t, uint*); int corral_getinfo(cid_t, uint, void*, uint*); int corral_getid(char *, cid_t *); long wpar_genmajor(void); int wpar_relmajor(long); int corral_setkstate(cid_t, uint, uint); int corral_wait_for_state_change(cid_t, uint*, uint); int wpar_dr_pre(corralp_t, cid_t, int, int *, class_id_t); int wpar_getclassindex(cid_t , class_id_t *); int wpar_cfgops(unsigned int , void *); int wpar_checkpoint_status(cid_t, int, void *); int cordata_config(cid_t, cordatap_t, uint); /* Device system calls */ int wpar_mkdevexport(cid_t, wdevexport_t*); int wpar_rmdevexport(cid_t, wdevexport_t*); int wpar_lsdevexport(cid_t, uint, wdevexport_t*); int wpar_mkdevimport(wdevimport_t*); int wpar_rmdevimport(wdevimport_t*); int wpar_lsdevimport(uint, wdevimport_t*); /* KE/DD export calls */ int wpar_KEexp(int, cid_t, wdevKEexport_t *, int *); int brand(brandp_t); /*WPAR Resource control systemcalls*/ int wpar_limits_config(cid_t cid,uint32_t *resources_set, wpar_limits_t *inlimits); int wpar_limits_modify(cid_t cid, uint32_t *resources_set,wpar_limits_t *inlimits); int wpar_limits_query(cid_t cid,uint *cmd_bit,wpar_limits_t * out_usage_or_limits, unsigned int *bufsize); int wpar_res_query (int ResourceType, int Action, long long* Limit); #ifdef __cplusplus } #endif #endif /* _CORRAL_H */