xref: /linux/tools/testing/selftests/powerpc/pmu/event.h (revision cb96143defbd5516c351595d56b608ed915b525e)
1*cb96143dSMichael Ellerman /*
2*cb96143dSMichael Ellerman  * Copyright 2013, Michael Ellerman, IBM Corp.
3*cb96143dSMichael Ellerman  * Licensed under GPLv2.
4*cb96143dSMichael Ellerman  */
5*cb96143dSMichael Ellerman 
6*cb96143dSMichael Ellerman #ifndef _SELFTESTS_POWERPC_PMU_EVENT_H
7*cb96143dSMichael Ellerman #define _SELFTESTS_POWERPC_PMU_EVENT_H
8*cb96143dSMichael Ellerman 
9*cb96143dSMichael Ellerman #include <unistd.h>
10*cb96143dSMichael Ellerman #include <linux/perf_event.h>
11*cb96143dSMichael Ellerman 
12*cb96143dSMichael Ellerman #include "utils.h"
13*cb96143dSMichael Ellerman 
14*cb96143dSMichael Ellerman 
15*cb96143dSMichael Ellerman struct event {
16*cb96143dSMichael Ellerman 	struct perf_event_attr attr;
17*cb96143dSMichael Ellerman 	char *name;
18*cb96143dSMichael Ellerman 	int fd;
19*cb96143dSMichael Ellerman 	/* This must match the read_format we use */
20*cb96143dSMichael Ellerman 	struct {
21*cb96143dSMichael Ellerman 		u64 value;
22*cb96143dSMichael Ellerman 		u64 running;
23*cb96143dSMichael Ellerman 		u64 enabled;
24*cb96143dSMichael Ellerman 	} result;
25*cb96143dSMichael Ellerman };
26*cb96143dSMichael Ellerman 
27*cb96143dSMichael Ellerman void event_init(struct event *e, u64 config);
28*cb96143dSMichael Ellerman void event_init_named(struct event *e, u64 config, char *name);
29*cb96143dSMichael Ellerman void event_init_opts(struct event *e, u64 config, int type, char *name);
30*cb96143dSMichael Ellerman int event_open_with_options(struct event *e, pid_t pid, int cpu, int group_fd);
31*cb96143dSMichael Ellerman int event_open_with_group(struct event *e, int group_fd);
32*cb96143dSMichael Ellerman int event_open(struct event *e);
33*cb96143dSMichael Ellerman void event_close(struct event *e);
34*cb96143dSMichael Ellerman int event_reset(struct event *e);
35*cb96143dSMichael Ellerman int event_read(struct event *e);
36*cb96143dSMichael Ellerman void event_report_justified(struct event *e, int name_width, int result_width);
37*cb96143dSMichael Ellerman void event_report(struct event *e);
38*cb96143dSMichael Ellerman 
39*cb96143dSMichael Ellerman #endif /* _SELFTESTS_POWERPC_PMU_EVENT_H */
40