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