cap_util.h revision b885580b43755ee4ea1e280b85428893d2ba9291
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CAP_UTIL_H
#define _SYS_CAP_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/cpc_impl.h>
#ifdef _KERNEL
/*
* Capacity and utilization flags for each CPU
*/
/*
* Macro that returns whether CPU performance counters turned on for given CPU
*/
/*
* Per counter statistics
*/
typedef struct cu_cntr_stats {
/*
* Counter info for a PG hardware sharing relationship
*/
typedef struct cu_cntr_info {
/*
* Each CPU can have one or more CPC contexts for measuring capacity and
* utilization
*
* One CPC context is needed per CPU if the counter events needed to measure
* capacity and utilization on each CPU can be programmed onto all the counters
* on a CPU at the same time and there are fewer or same number of desired
* counter events as counters on each CPU. Otherwise, the desired counter
* events are assigned across multiple CPC contexts, so the contexts and their
* counter events can be multiplexed onto the counters over time to get the
* data for all of the counter events.
*/
typedef struct cu_cpc_ctx {
int cur_index; /* index for current context */
int nctx; /* number of CPC contexts */
} cu_cpc_ctx_t;
/*
* Per CPU capacity and utilization info
*/
typedef struct cu_cpu_info {
/*
* Per PG hardware sharing relationship counter info
*/
/*
* COMMON INTERFACE ROUTINES
*/
/*
* Setup capacity and utilization support
*/
extern void cu_init(void);
/*
* Tear down capacity and utilization support
*/
extern int cu_fini(void);
/*
* Program CPC for capacity and utilization on given CPU
*/
extern void cu_cpc_program(struct cpu *, int *);
/*
* Unprogram CPC for capacity and utilization on given CPU
*/
extern void cu_cpc_unprogram(struct cpu *, int *);
/*
* Update counter statistics on a given CPU
*/
/*
* Update utilization and capacity data for CMT PG
*/
extern void cu_pg_update(pghw_t *);
/*
* Disable or enable capacity and utilization on all CPUs
*/
extern void cu_disable(void);
extern void cu_enable(void);
/*
* PLATFORM SPECIFIC INTERFACE ROUTINES
*/
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CAP_UTIL_H */