xref: /titanic_52/usr/src/uts/common/sys/project.h (revision c6939658adb0a356a77bc28f7df252ceb4a8f6cc)
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
5824c205fSml93401  * Common Development and Distribution License (the "License").
6824c205fSml93401  * 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 /*
22824c205fSml93401  * 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 #ifndef	_SYS_PROJECT_H
277c478bd9Sstevel@tonic-gate #define	_SYS_PROJECT_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
377c478bd9Sstevel@tonic-gate #include <sys/rctl.h>
38824c205fSml93401 #include <sys/ipc_rctl.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate typedef struct kproject_data {		/* Datum protected by: */
417c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpd_shmmax;	/* shm's ipcs_lock */
42824c205fSml93401 	ipc_rqty_t	kpd_ipc;	/* shm|sem|msg's ipcs lock */
43*c6939658Ssl108498 	rctl_qty_t	kpd_locked_mem;	 /* zone_rctl_lock */
44*c6939658Ssl108498 	rctl_qty_t	kpd_locked_mem_ctl; /* kpj_rctls->rcs_lock */
457c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpd_contract;	/* contract_lock */
467c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
47*c6939658Ssl108498 
487c478bd9Sstevel@tonic-gate } kproject_data_t;
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * The first two fields of this structure must not be reordered.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate typedef struct kproject {
547c478bd9Sstevel@tonic-gate 	projid_t 	kpj_id;		/* project ID		*/
557c478bd9Sstevel@tonic-gate 	zoneid_t	kpj_zoneid;	/* zone ID		*/
567c478bd9Sstevel@tonic-gate 	uint_t		kpj_count;	/* reference counter	*/
577c478bd9Sstevel@tonic-gate 	uint32_t	kpj_shares;	/* number of shares	*/
587c478bd9Sstevel@tonic-gate 	rctl_set_t	*kpj_rctls;	/* resource control set */
597c478bd9Sstevel@tonic-gate 	struct kproject	*kpj_prev;	/* previous project	*/
607c478bd9Sstevel@tonic-gate 	struct kproject	*kpj_next;	/* next project		*/
617c478bd9Sstevel@tonic-gate 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
627c478bd9Sstevel@tonic-gate 	kmutex_t	kpj_poolbind;	/* synch. with pools	*/
637c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
647c478bd9Sstevel@tonic-gate 					/* zone_nlwps_lock */
657c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
667c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
677c478bd9Sstevel@tonic-gate 					/* zone_nlwps_lock */
687c478bd9Sstevel@tonic-gate 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
697c478bd9Sstevel@tonic-gate } kproject_t;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #ifdef _KERNEL
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * Flags for project_hold_by_id()
757c478bd9Sstevel@tonic-gate  */
767c478bd9Sstevel@tonic-gate #define	PROJECT_HOLD_FIND	1
777c478bd9Sstevel@tonic-gate #define	PROJECT_HOLD_INSERT	2
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate void project_init(void);
807c478bd9Sstevel@tonic-gate kproject_t *project_hold(kproject_t *);
817c478bd9Sstevel@tonic-gate kproject_t *project_hold_by_id(projid_t, zoneid_t, int);
827c478bd9Sstevel@tonic-gate void project_rele(kproject_t *);
837c478bd9Sstevel@tonic-gate int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
847c478bd9Sstevel@tonic-gate projid_t curprojid(void);
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate extern kproject_t *proj0p;
877c478bd9Sstevel@tonic-gate extern rctl_hndl_t rc_project_nlwps;
887c478bd9Sstevel@tonic-gate extern rctl_hndl_t rc_project_ntasks;
89*c6939658Ssl108498 extern rctl_hndl_t rc_project_locked_mem;
907c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate #endif
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #endif	/* _SYS_PROJECT_H */
97