]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/xen/interface/xenoprof.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / xen / interface / xenoprof.h
1 /******************************************************************************
2  * xenoprof.h
3  * 
4  * Interface for enabling system wide profiling based on hardware performance
5  * counters
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
9  * deal in the Software without restriction, including without limitation the
10  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  * Copyright (C) 2005 Hewlett-Packard Co.
26  * Written by Aravind Menon & Jose Renato Santos
27  */
28
29 #ifndef __XEN_PUBLIC_XENOPROF_H__
30 #define __XEN_PUBLIC_XENOPROF_H__
31
32 #include "xen.h"
33
34 /*
35  * Commands to HYPERVISOR_xenoprof_op().
36  */
37 #define XENOPROF_init                0
38 #define XENOPROF_reset_active_list   1
39 #define XENOPROF_reset_passive_list  2
40 #define XENOPROF_set_active          3
41 #define XENOPROF_set_passive         4
42 #define XENOPROF_reserve_counters    5
43 #define XENOPROF_counter             6
44 #define XENOPROF_setup_events        7
45 #define XENOPROF_enable_virq         8
46 #define XENOPROF_start               9
47 #define XENOPROF_stop               10
48 #define XENOPROF_disable_virq       11
49 #define XENOPROF_release_counters   12
50 #define XENOPROF_shutdown           13
51 #define XENOPROF_get_buffer         14
52 #define XENOPROF_set_backtrace      15
53
54 /* AMD IBS support */
55 #define XENOPROF_get_ibs_caps       16
56 #define XENOPROF_ibs_counter        17
57 #define XENOPROF_last_op            17
58
59 #define MAX_OPROF_EVENTS    32
60 #define MAX_OPROF_DOMAINS   25
61 #define XENOPROF_CPU_TYPE_SIZE 64
62
63 /* Xenoprof performance events (not Xen events) */
64 struct event_log {
65     uint64_t eip;
66     uint8_t mode;
67     uint8_t event;
68 };
69
70 /* PC value that indicates a special code */
71 #define XENOPROF_ESCAPE_CODE (~0ULL)
72 /* Transient events for the xenoprof->oprofile cpu buf */
73 #define XENOPROF_TRACE_BEGIN 1
74
75 /* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
76 struct xenoprof_buf {
77     uint32_t event_head;
78     uint32_t event_tail;
79     uint32_t event_size;
80     uint32_t vcpu_id;
81     uint64_t xen_samples;
82     uint64_t kernel_samples;
83     uint64_t user_samples;
84     uint64_t lost_samples;
85     struct event_log event_log[1];
86 };
87 #ifndef __XEN__
88 typedef struct xenoprof_buf xenoprof_buf_t;
89 DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
90 #endif
91
92 struct xenoprof_init {
93     int32_t  num_events;
94     int32_t  is_primary;
95     char cpu_type[XENOPROF_CPU_TYPE_SIZE];
96 };
97 typedef struct xenoprof_init xenoprof_init_t;
98 DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
99
100 struct xenoprof_get_buffer {
101     int32_t  max_samples;
102     int32_t  nbuf;
103     int32_t  bufsize;
104     uint64_t buf_gmaddr;
105 };
106 typedef struct xenoprof_get_buffer xenoprof_get_buffer_t;
107 DEFINE_XEN_GUEST_HANDLE(xenoprof_get_buffer_t);
108
109 struct xenoprof_counter {
110     uint32_t ind;
111     uint64_t count;
112     uint32_t enabled;
113     uint32_t event;
114     uint32_t hypervisor;
115     uint32_t kernel;
116     uint32_t user;
117     uint64_t unit_mask;
118 };
119 typedef struct xenoprof_counter xenoprof_counter_t;
120 DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
121
122 typedef struct xenoprof_passive {
123     uint16_t domain_id;
124     int32_t  max_samples;
125     int32_t  nbuf;
126     int32_t  bufsize;
127     uint64_t buf_gmaddr;
128 } xenoprof_passive_t;
129 DEFINE_XEN_GUEST_HANDLE(xenoprof_passive_t);
130
131 struct xenoprof_ibs_counter {
132     uint64_t op_enabled;
133     uint64_t fetch_enabled;
134     uint64_t max_cnt_fetch;
135     uint64_t max_cnt_op;
136     uint64_t rand_en;
137     uint64_t dispatched_ops;
138 };
139 typedef struct xenoprof_ibs_counter xenoprof_ibs_counter_t;
140 DEFINE_XEN_GUEST_HANDLE(xenoprof_ibs_counter_t);
141
142 #endif /* __XEN_PUBLIC_XENOPROF_H__ */
143
144 /*
145  * Local variables:
146  * mode: C
147  * c-set-style: "BSD"
148  * c-basic-offset: 4
149  * tab-width: 4
150  * indent-tabs-mode: nil
151  * End:
152  */