The Gaudi Framework  v32r2 (46d42edc)
pfmlib_amd64.h
Go to the documentation of this file.
1 /*
2  * AMD64 PMU specific types and definitions (64 and 32 bit modes)
3  *
4  * Copyright (c) 2005-2006 Hewlett-Packard Development Company, L.P.
5  * Contributed by Stephane Eranian <eranian@hpl.hp.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11  * of the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef __PFMLIB_AMD64_H__
26 #define __PFMLIB_AMD64_H__
27 
28 #include <stdint.h>
29 
30 /*
31  * privilege level mask usage for AMD64:
32  *
33  * PFM_PLM0 = OS (kernel, hypervisor, ..)
34  * PFM_PLM1 = invalid parameters
35  * PFM_PLM2 = invalid parameters
36  * PFM_PLM3 = USR (user level)
37  */
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #define PMU_AMD64_MAX_COUNTERS 4 /* total numbers of performance counters */
44 
45 /*
46  * AMD64 MSR definitions
47  */
48 
49 typedef union {
50  uint64_t val; /* complete register value */
51  struct {
52  uint64_t sel_event_mask : 8; /* event mask */
53  uint64_t sel_unit_mask : 8; /* unit mask */
54  uint64_t sel_usr : 1; /* user level */
55  uint64_t sel_os : 1; /* system level */
56  uint64_t sel_edge : 1; /* edge detec */
57  uint64_t sel_pc : 1; /* pin control */
58  uint64_t sel_int : 1; /* enable APIC intr */
59  uint64_t sel_res1 : 1; /* reserved */
60  uint64_t sel_en : 1; /* enable */
61  uint64_t sel_inv : 1; /* invert counter mask */
62  uint64_t sel_cnt_mask : 8; /* counter mask */
63  uint64_t sel_event_mask2 : 4; /* 10h only: event mask [11:8] */
64  uint64_t sel_res2 : 4; /* reserved */
65  uint64_t sel_guest : 1; /* 10h only: guest only counter */
66  uint64_t sel_host : 1; /* 10h only: host only counter */
67  uint64_t sel_res3 : 22; /* reserved */
68  } perfsel;
69 } pfm_amd64_sel_reg_t; /* MSR 0xc001000-0xc001003 */
70 
71 typedef union {
72  uint64_t val; /* complete register value */
73  struct {
74  uint64_t ctr_count : 48; /* 48-bit hardware counter */
75  uint64_t ctr_res1 : 16; /* reserved */
76  } perfctr;
77 } pfm_amd64_ctr_reg_t; /* MSR 0xc001004-0xc001007 */
78 
79 typedef union {
80  uint64_t val; /* complete register value */
81  struct {
95  } reg;
96 } ibsfetchctl_t; /* MSR 0xc0011030 */
97 
98 typedef union {
99  uint64_t val; /* complete register value */
100  struct {
107  } reg;
108 } ibsopctl_t; /* MSR 0xc0011033 */
109 
110 typedef union {
111  uint64_t val; /* complete register value */
112  struct {
122  } reg;
123 } ibsopdata_t; /* MSR 0xc0011035 */
124 
125 typedef union {
126  uint64_t val; /* complete register value */
127  struct {
133  } reg;
134 } ibsopdata2_t; /* MSR 0xc0011036 */
135 
136 typedef union {
137  uint64_t val; /* complete register value */
138  struct {
161  } reg;
162 } ibsopdata3_t; /* MSR 0xc0011037 */
163 
164 /*
165  * AMD64 specific input parameters for the library
166  */
167 
168 typedef struct {
169  uint32_t cnt_mask; /* threshold ([4-255] are reserved) */
170  uint32_t flags; /* counter specific flag */
172 
173 #define PFM_AMD64_SEL_INV 0x1 /* inverse */
174 #define PFM_AMD64_SEL_EDGE 0x2 /* edge detect */
175 #define PFM_AMD64_SEL_GUEST 0x4 /* guest only */
176 #define PFM_AMD64_SEL_HOST 0x8 /* host only */
177 
178 /*
179  * IBS input parameters
180  *
181  * Maxcnt specifies the maximum count value of the periodic counter,
182  * 20 bits, bits 3:0 are always set to zero.
183  */
184 typedef struct {
185  unsigned int maxcnt;
186  unsigned int options;
187 } ibs_param_t;
188 
189 /*
190  * values for ibs_param_t.options
191  */
192 #define IBS_OPTIONS_RANDEN 1 /* enable randomization (IBS fetch only) */
193 #define IBS_OPTIONS_UOPS 1 /* count dispatched uops (IBS op only) */
194 
195 typedef struct {
196  pfmlib_amd64_counter_t pfp_amd64_counters[PMU_AMD64_MAX_COUNTERS]; /* extended counter features */
197  uint32_t flags; /* use flags */
198  uint32_t reserved1; /* for future use */
199  ibs_param_t ibsfetch; /* IBS fetch control */
200  ibs_param_t ibsop; /* IBS execution control */
201  uint64_t reserved2; /* for future use */
203 
204 /* A bit mask, meaning multiple usage types may be defined */
205 #define PFMLIB_AMD64_USE_IBSFETCH 1
206 #define PFMLIB_AMD64_USE_IBSOP 2
207 
208 /*
209  * AMD64 specific output parameters for the library
210  *
211  * The values ibsfetch_base and ibsop_base pass back the index of the
212  * ibsopctl and ibsfetchctl register in pfp_pmds[].
213  */
214 
215 typedef struct {
216  uint32_t ibsfetch_base; /* Perfmon2 base register index */
217  uint32_t ibsop_base; /* Perfmon2 base register index */
218  uint64_t reserved[7]; /* for future use */
220 
221 /* Perfmon2 registers relative to base register */
222 #define PMD_IBSFETCHCTL 0
223 #define PMD_IBSFETCHLINAD 1
224 #define PMD_IBSFETCHPHYSAD 2
225 #define PMD_IBSOPCTL 0
226 #define PMD_IBSOPRIP 1
227 #define PMD_IBSOPDATA 2
228 #define PMD_IBSOPDATA2 3
229 #define PMD_IBSOPDATA3 4
230 #define PMD_IBSDCLINAD 5
231 #define PMD_IBSDCPHYSAD 6
232 
233 #ifdef __cplusplus /* extern C */
234 }
235 #endif
236 
237 #endif /* __PFMLIB_AMD64_H__ */
uint64_t ibsdcl1tlbmiss
Definition: pfmlib_amd64.h:141
uint64_t ibsopbrnret
Definition: pfmlib_amd64.h:120
uint64_t sel_unit_mask
Definition: pfmlib_amd64.h:53
uint64_t ibsdcsttoldcan
Definition: pfmlib_amd64.h:151
uint64_t ibsdcstbnkcon
Definition: pfmlib_amd64.h:149
uint64_t ibsdcmissacc
Definition: pfmlib_amd64.h:147
uint64_t nbibsreqcachehitst
Definition: pfmlib_amd64.h:131
uint64_t ibsdcmabhit
Definition: pfmlib_amd64.h:155
uint64_t ibsfetchcomp
Definition: pfmlib_amd64.h:87
uint64_t ibsdcl1tlbhit1g
Definition: pfmlib_amd64.h:144
uint64_t ibsopbrnmisp
Definition: pfmlib_amd64.h:119
uint64_t ibsdcldbnkcon
Definition: pfmlib_amd64.h:148
uint64_t ibsfetchen
Definition: pfmlib_amd64.h:85
uint64_t ibsdcwcmemacc
Definition: pfmlib_amd64.h:153
uint64_t ibsfetchval
Definition: pfmlib_amd64.h:86
uint64_t nbibsreqsrc
Definition: pfmlib_amd64.h:128
uint64_t ibsfetchlat
Definition: pfmlib_amd64.h:84
uint64_t ibsfetchcnt
Definition: pfmlib_amd64.h:83
uint64_t ibstagtoretctr
Definition: pfmlib_amd64.h:114
unsigned long long uint64_t
Definition: instrset.h:143
uint64_t nbibsreqdstproc
Definition: pfmlib_amd64.h:130
uint64_t ibsopreturn
Definition: pfmlib_amd64.h:117
#define PMU_AMD64_MAX_COUNTERS
Definition: pfmlib_amd64.h:43
uint64_t ibsdcl2tlbhit2m
Definition: pfmlib_amd64.h:145
uint64_t ibsopen
Definition: pfmlib_amd64.h:103
uint64_t ibsopcntl
Definition: pfmlib_amd64.h:105
uint64_t reserved1
Definition: pfmlib_amd64.h:129
uint64_t ibsranden
Definition: pfmlib_amd64.h:93
uint64_t reserved2
Definition: pfmlib_amd64.h:160
uint64_t ibsdcl1tlbhit2m
Definition: pfmlib_amd64.h:143
uint64_t sel_event_mask2
Definition: pfmlib_amd64.h:63
uint64_t ibsdcmiss
Definition: pfmlib_amd64.h:146
uint64_t val
Definition: pfmlib_amd64.h:126
uint64_t ibscomptoretctr
Definition: pfmlib_amd64.h:113
uint64_t ibsdcphyaddrvalid
Definition: pfmlib_amd64.h:157
uint64_t val
Definition: pfmlib_amd64.h:80
unsigned int options
Definition: pfmlib_amd64.h:186
uint64_t ibsdcsttoldfwd
Definition: pfmlib_amd64.h:150
uint64_t reserved2
Definition: pfmlib_amd64.h:106
uint64_t ibsopmaxcnt
Definition: pfmlib_amd64.h:101
uint64_t reserved1
Definition: pfmlib_amd64.h:158
uint64_t ibsstop
Definition: pfmlib_amd64.h:140
uint64_t ibsdcl2tlbmiss
Definition: pfmlib_amd64.h:142
uint64_t ibsldop
Definition: pfmlib_amd64.h:139
uint64_t val
Definition: pfmlib_amd64.h:99
unsigned int uint32_t
Definition: instrset.h:141
unsigned int maxcnt
Definition: pfmlib_amd64.h:185
uint64_t ibsdclockedop
Definition: pfmlib_amd64.h:154
uint64_t ibsl1tlbpgsz
Definition: pfmlib_amd64.h:90
uint64_t reserved2
Definition: pfmlib_amd64.h:132
uint64_t val
Definition: pfmlib_amd64.h:137
uint64_t sel_event_mask
Definition: pfmlib_amd64.h:52
uint64_t ibsdcucmemacc
Definition: pfmlib_amd64.h:152
uint64_t reserved
Definition: pfmlib_amd64.h:94
uint64_t reserved1
Definition: pfmlib_amd64.h:102
uint64_t ibsopbrntaken
Definition: pfmlib_amd64.h:118
uint64_t ibsfetchmaxcnt
Definition: pfmlib_amd64.h:82
uint64_t ibsl2tlbmiss
Definition: pfmlib_amd64.h:92
uint64_t ibsl1tlbmiss
Definition: pfmlib_amd64.h:91
uint64_t ibsopmispreturn
Definition: pfmlib_amd64.h:116
uint64_t reserved
Definition: pfmlib_amd64.h:121
uint64_t ibsopval
Definition: pfmlib_amd64.h:104
uint64_t ibsdclinaddrvalid
Definition: pfmlib_amd64.h:156
uint64_t ibsopbrnresync
Definition: pfmlib_amd64.h:115
uint64_t ibsdcmisslat
Definition: pfmlib_amd64.h:159
uint64_t val
Definition: pfmlib_amd64.h:111
uint64_t ibsphyaddrvalid
Definition: pfmlib_amd64.h:89
uint64_t ibsicmiss
Definition: pfmlib_amd64.h:88