kcpc.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_KCPC_H
#define _SYS_KCPC_H
#include <sys/cpc_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Kernel clients need this file in order to know what a request is and how to
* program one.
*/
typedef struct _kcpc_set kcpc_set_t;
#ifdef _KERNEL
/*
* Forward declarations.
*/
struct _kthread;
struct cpu;
typedef struct _kcpc_request kcpc_request_t;
struct __pcbe_ops;
struct _kcpc_set {
int ks_flags;
int ks_nreqs; /* Number of reqs */
};
struct _kcpc_request {
void *kr_config;
int kr_index; /* indx of data for this req */
int kr_picnum; /* Number of phys pic */
char kr_event[CPC_MAX_EVENT_LEN];
void *kr_ptr; /* Ptr assigned by requester */
};
typedef struct _kcpc_request_list {
int krl_cnt; /* how many requests */
int krl_max; /* max request entries */
/*
* Type of update function to be called when reading counters on current CPU in
* kcpc_read()
*/
typedef int (*kcpc_update_func_t)(void *, uint64_t);
/*
* Type of read function to be called when reading counters on current CPU
* (ie. should be same type signature as kcpc_read())
*/
typedef int (*kcpc_read_func_t)(kcpc_update_func_t);
/*
* Initialize the kcpc framework
*/
extern int kcpc_init(void);
/*
* Bind the set to the indicated thread.
* Returns 0 on success, or an errno in case of error. If EINVAL is returned,
* a specific error code will be returned in the subcode parameter.
*/
/*
* Bind the set to the indicated CPU.
* Same return convention as kcpc_bind_thread().
*/
/*
* Request the system to sample the current state of the set into users buf.
*/
/*
* Create CPC context containing specified list of requested counter events
*/
/*
* Returns whether specified counter event is supported
*/
/*
* Initialize list of CPC event requests
*/
/*
* Add counter event request to given list of counter event requests
*/
int kmem_flags);
/*
* Reset list of CPC event requests so its space can be used for another set
* of requests
*/
/*
* Free given list of counter event requests
*/
/*
* Read CPC data for given event on current CPU
*/
extern int kcpc_read(kcpc_update_func_t);
/*
* Program current CPU with given CPC context
*/
/*
* Unprogram CPC counters on current CPU
*/
/*
* Unbind a request and release the associated resources.
*/
/*
* Preset the indicated request's counter and underlying PCBE config to the
* given value.
*/
/*
* Unfreeze the set and get it counting again.
*/
/*
* Mark a thread's CPC context, if it exists, INVALID.
*/
extern void kcpc_invalidate(struct _kthread *t);
extern int kcpc_overflow_ast(void);
extern int kcpc_hw_lwp_hook(void);
extern int kcpc_cpuctx; /* number of cpu-specific contexts */
/*
* 'dtrace_cpc_in_use' contains the number of currently active cpc provider
* based enablings. See the block comment in uts/common/os/dtrace_subr.c for
* details of its actual usage.
*/
extern uint32_t dtrace_cpc_in_use;
extern void (*dtrace_cpc_fire)(uint64_t);
extern void kcpc_invalidate_config(void *token);
extern char *kcpc_list_attrs(void);
extern uint_t kcpc_pcbe_capabilities(void);
extern int kcpc_pcbe_loaded(void);
/*
* Called by a PCBE to determine if nonprivileged access to counters should be
* allowed. Returns non-zero if non-privileged access is allowed, 0 if not.
*/
extern int kcpc_allow_nonpriv(void *token);
extern void kcpc_register_pcbe(struct __pcbe_ops *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_KCPC_H */