1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Performance event support - s390 specific definitions. 4 * 5 * Copyright IBM Corp. 2009, 2017 6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 7 * Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 8 */ 9 10 #ifndef _ASM_S390_PERF_EVENT_H 11 #define _ASM_S390_PERF_EVENT_H 12 13 #include <linux/perf_event.h> 14 #include <linux/device.h> 15 16 /* Per-CPU flags for PMU states */ 17 #define PMU_F_RESERVED 0x1000 18 #define PMU_F_ENABLED 0x2000 19 #define PMU_F_IN_USE 0x4000 20 #define PMU_F_ERR_IBE 0x0100 21 #define PMU_F_ERR_LSDA 0x0200 22 #define PMU_F_ERR_MASK (PMU_F_ERR_IBE|PMU_F_ERR_LSDA) 23 24 /* Perf definitions for PMU event attributes in sysfs */ 25 extern __init const struct attribute_group **cpumf_cf_event_group(void); 26 extern ssize_t cpumf_events_sysfs_show(struct device *dev, 27 struct device_attribute *attr, 28 char *page); 29 #define EVENT_VAR(_cat, _name) event_attr_##_cat##_##_name 30 #define EVENT_PTR(_cat, _name) (&EVENT_VAR(_cat, _name).attr.attr) 31 32 #define CPUMF_EVENT_ATTR(cat, name, id) \ 33 PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show) 34 #define CPUMF_EVENT_PTR(cat, name) EVENT_PTR(cat, name) 35 36 37 /* Perf callbacks */ 38 struct pt_regs; 39 extern unsigned long perf_instruction_pointer(struct pt_regs *regs); 40 extern unsigned long perf_misc_flags(struct pt_regs *regs); 41 #define perf_misc_flags(regs) perf_misc_flags(regs) 42 #define perf_arch_bpf_user_pt_regs(regs) ®s->user_regs 43 44 /* Perf pt_regs extension for sample-data-entry indicators */ 45 struct perf_sf_sde_regs { 46 unsigned char in_guest:1; /* guest sample */ 47 unsigned long reserved:63; /* reserved */ 48 }; 49 50 /* Perf PMU definitions for the counter facility */ 51 #define PERF_CPUM_CF_MAX_CTR 0xffffUL /* Max ctr for ECCTR */ 52 53 /* Perf PMU definitions for the sampling facility */ 54 #define PERF_CPUM_SF_MAX_CTR 2 55 #define PERF_EVENT_CPUM_SF 0xB0000UL /* Event: Basic-sampling */ 56 #define PERF_EVENT_CPUM_SF_DIAG 0xBD000UL /* Event: Combined-sampling */ 57 #define PERF_EVENT_CPUM_CF_DIAG 0xBC000UL /* Event: Counter sets */ 58 #define PERF_CPUM_SF_BASIC_MODE 0x0001 /* Basic-sampling flag */ 59 #define PERF_CPUM_SF_DIAG_MODE 0x0002 /* Diagnostic-sampling flag */ 60 #define PERF_CPUM_SF_MODE_MASK (PERF_CPUM_SF_BASIC_MODE| \ 61 PERF_CPUM_SF_DIAG_MODE) 62 #define PERF_CPUM_SF_FULL_BLOCKS 0x0004 /* Process full SDBs only */ 63 #define PERF_CPUM_SF_FREQ_MODE 0x0008 /* Sampling with frequency */ 64 65 #define REG_NONE 0 66 #define REG_OVERFLOW 1 67 #define OVERFLOW_REG(hwc) ((hwc)->extra_reg.config) 68 #define SFB_ALLOC_REG(hwc) ((hwc)->extra_reg.alloc) 69 #define TEAR_REG(hwc) ((hwc)->last_tag) 70 #define SAMPL_RATE(hwc) ((hwc)->event_base) 71 #define SAMPL_FLAGS(hwc) ((hwc)->config_base) 72 #define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE) 73 #define SDB_FULL_BLOCKS(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FULL_BLOCKS) 74 #define SAMPLE_FREQ_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FREQ_MODE) 75 76 #endif /* _ASM_S390_PERF_EVENT_H */ 77