1f50a7f3dSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2cb96143dSMichael Ellerman /* 3cb96143dSMichael Ellerman * Copyright 2013, Michael Ellerman, IBM Corp. 4cb96143dSMichael Ellerman */ 5cb96143dSMichael Ellerman 6cb96143dSMichael Ellerman #ifndef _SELFTESTS_POWERPC_PMU_EVENT_H 7cb96143dSMichael Ellerman #define _SELFTESTS_POWERPC_PMU_EVENT_H 8cb96143dSMichael Ellerman 9cb96143dSMichael Ellerman #include <unistd.h> 10cb96143dSMichael Ellerman #include <linux/perf_event.h> 11cb96143dSMichael Ellerman 12cb96143dSMichael Ellerman #include "utils.h" 13cb96143dSMichael Ellerman 14cb96143dSMichael Ellerman 15cb96143dSMichael Ellerman struct event { 16cb96143dSMichael Ellerman struct perf_event_attr attr; 17cb96143dSMichael Ellerman char *name; 18cb96143dSMichael Ellerman int fd; 19cb96143dSMichael Ellerman /* This must match the read_format we use */ 20cb96143dSMichael Ellerman struct { 21cb96143dSMichael Ellerman u64 value; 22cb96143dSMichael Ellerman u64 running; 23cb96143dSMichael Ellerman u64 enabled; 24cb96143dSMichael Ellerman } result; 25f961e20fSAthira Rajeev /* 26f961e20fSAthira Rajeev * mmap buffer used while recording sample. 27f961e20fSAthira Rajeev * Accessed as "struct perf_event_mmap_page" 28f961e20fSAthira Rajeev */ 29f961e20fSAthira Rajeev void *mmap_buffer; 30cb96143dSMichael Ellerman }; 31cb96143dSMichael Ellerman 32cb96143dSMichael Ellerman void event_init(struct event *e, u64 config); 33cb96143dSMichael Ellerman void event_init_named(struct event *e, u64 config, char *name); 34cb96143dSMichael Ellerman void event_init_opts(struct event *e, u64 config, int type, char *name); 35*54d4ba7fSMadhavan Srinivasan void event_init_sampling(struct event *e, u64 config); 36cb96143dSMichael Ellerman int event_open_with_options(struct event *e, pid_t pid, int cpu, int group_fd); 37cb96143dSMichael Ellerman int event_open_with_group(struct event *e, int group_fd); 383752e453SMichael Ellerman int event_open_with_pid(struct event *e, pid_t pid); 393752e453SMichael Ellerman int event_open_with_cpu(struct event *e, int cpu); 40cb96143dSMichael Ellerman int event_open(struct event *e); 41cb96143dSMichael Ellerman void event_close(struct event *e); 423752e453SMichael Ellerman int event_enable(struct event *e); 433752e453SMichael Ellerman int event_disable(struct event *e); 44cb96143dSMichael Ellerman int event_reset(struct event *e); 45cb96143dSMichael Ellerman int event_read(struct event *e); 46cb96143dSMichael Ellerman void event_report_justified(struct event *e, int name_width, int result_width); 47cb96143dSMichael Ellerman void event_report(struct event *e); 48cb96143dSMichael Ellerman 49cb96143dSMichael Ellerman #endif /* _SELFTESTS_POWERPC_PMU_EVENT_H */ 50