xref: /openbmc/linux/arch/s390/include/asm/perf_event.h (revision 275876e2)
1 /*
2  * Performance event support - s390 specific definitions.
3  *
4  * Copyright IBM Corp. 2009, 2013
5  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6  *	      Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
7  */
8 
9 #ifndef _ASM_S390_PERF_EVENT_H
10 #define _ASM_S390_PERF_EVENT_H
11 
12 #ifdef CONFIG_64BIT
13 
14 #include <linux/perf_event.h>
15 #include <linux/device.h>
16 #include <asm/cpu_mf.h>
17 
18 /* Per-CPU flags for PMU states */
19 #define PMU_F_RESERVED			0x1000
20 #define PMU_F_ENABLED			0x2000
21 #define PMU_F_IN_USE			0x4000
22 #define PMU_F_ERR_IBE			0x0100
23 #define PMU_F_ERR_LSDA			0x0200
24 #define PMU_F_ERR_MASK			(PMU_F_ERR_IBE|PMU_F_ERR_LSDA)
25 
26 /* Perf defintions for PMU event attributes in sysfs */
27 extern __init const struct attribute_group **cpumf_cf_event_group(void);
28 extern ssize_t cpumf_events_sysfs_show(struct device *dev,
29 				       struct device_attribute *attr,
30 				       char *page);
31 #define EVENT_VAR(_cat, _name)		event_attr_##_cat##_##_name
32 #define EVENT_PTR(_cat, _name)		(&EVENT_VAR(_cat, _name).attr.attr)
33 
34 #define CPUMF_EVENT_ATTR(cat, name, id)			\
35 	PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show)
36 #define CPUMF_EVENT_PTR(cat, name)	EVENT_PTR(cat, name)
37 
38 
39 /* Perf callbacks */
40 struct pt_regs;
41 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
42 extern unsigned long perf_misc_flags(struct pt_regs *regs);
43 #define perf_misc_flags(regs) perf_misc_flags(regs)
44 
45 /* Perf pt_regs extension for sample-data-entry indicators */
46 struct perf_sf_sde_regs {
47 	unsigned char in_guest:1;	  /* guest sample */
48 	unsigned long reserved:63;	  /* reserved */
49 };
50 
51 /* Perf PMU definitions for the counter facility */
52 #define PERF_CPUM_CF_MAX_CTR		256
53 
54 /* Perf PMU definitions for the sampling facility */
55 #define PERF_CPUM_SF_MAX_CTR		2
56 #define PERF_EVENT_CPUM_SF		0xB0000UL /* Event: Basic-sampling */
57 #define PERF_EVENT_CPUM_SF_DIAG		0xBD000UL /* Event: Combined-sampling */
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 
64 #define REG_NONE		0
65 #define REG_OVERFLOW		1
66 #define OVERFLOW_REG(hwc)	((hwc)->extra_reg.config)
67 #define SFB_ALLOC_REG(hwc)	((hwc)->extra_reg.alloc)
68 #define RAWSAMPLE_REG(hwc)	((hwc)->config)
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 
75 /* Structure for sampling data entries to be passed as perf raw sample data
76  * to user space.  Note that raw sample data must be aligned and, thus, might
77  * be padded with zeros.
78  */
79 struct sf_raw_sample {
80 #define SF_RAW_SAMPLE_BASIC	PERF_CPUM_SF_BASIC_MODE
81 #define SF_RAW_SAMPLE_DIAG	PERF_CPUM_SF_DIAG_MODE
82 	u64			format;
83 	u32			 size;	  /* Size of sf_raw_sample */
84 	u16			bsdes;	  /* Basic-sampling data entry size */
85 	u16			dsdes;	  /* Diagnostic-sampling data entry size */
86 	struct hws_basic_entry	basic;	  /* Basic-sampling data entry */
87 	struct hws_diag_entry	 diag;	  /* Diagnostic-sampling data entry */
88 	u8		    padding[];	  /* Padding to next multiple of 8 */
89 } __packed;
90 
91 /* Perf hardware reserve and release functions */
92 int perf_reserve_sampling(void);
93 void perf_release_sampling(void);
94 
95 #endif /* CONFIG_64BIT */
96 #endif /* _ASM_S390_PERF_EVENT_H */
97