radix: Implement radix_tree_destroy()
[akaros.git] / user / perfmon / pfmlib_intel_ivbep_unc_pcu.c
1 /*
2  * pfmlib_intel_ivbep_unc_pcu.c : Intel IvyBridge-EP Power Control Unit (PCU) uncore PMU
3  *
4  * Copyright (c) 2014 Google Inc. All rights reserved
5  * Contributed by Stephane Eranian <eranian@gmail.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 #include <sys/types.h>
25 #include <ctype.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29
30 /* private headers */
31 #include "pfmlib_priv.h"
32 #include "pfmlib_intel_x86_priv.h"
33 #include "pfmlib_intel_snbep_unc_priv.h"
34 #include "events/intel_ivbep_unc_pcu_events.h"
35
36 static void
37 display_pcu(void *this, pfmlib_event_desc_t *e, void *val)
38 {
39         const intel_x86_entry_t *pe = this_pe(this);
40         pfm_snbep_unc_reg_t *reg = val;
41         pfm_snbep_unc_reg_t f;
42
43         __pfm_vbprintf("[UNC_PCU=0x%"PRIx64" event=0x%x sel_ext=%d occ_sel=0x%x en=%d "
44                         "edge=%d thres=%d occ_inv=%d occ_edge=%d] %s\n",
45                         reg->val,
46                         reg->ivbep_pcu.unc_event,
47                         reg->ivbep_pcu.unc_sel_ext,
48                         reg->ivbep_pcu.unc_occ,
49                         reg->ivbep_pcu.unc_en,
50                         reg->ivbep_pcu.unc_edge,
51                         reg->ivbep_pcu.unc_thres,
52                         reg->ivbep_pcu.unc_occ_inv,
53                         reg->ivbep_pcu.unc_occ_edge,
54                         pe[e->event].name);
55
56         if (e->count == 1)
57                 return;
58
59         f.val = e->codes[1];
60
61         __pfm_vbprintf("[UNC_PCU_FILTER=0x%"PRIx64" band0=%u band1=%u band2=%u band3=%u]\n",
62                         f.val,
63                         f.pcu_filt.filt0,
64                         f.pcu_filt.filt1,
65                         f.pcu_filt.filt2,
66                         f.pcu_filt.filt3);
67 }
68
69
70 pfmlib_pmu_t intel_ivbep_unc_pcu_support = {
71         .desc                   = "Intel Ivy Bridge-EP PCU uncore",
72         .name                   = "ivbep_unc_pcu",
73         .perf_name              = "uncore_pcu",
74         .pmu                    = PFM_PMU_INTEL_IVBEP_UNC_PCU,
75         .pme_count              = LIBPFM_ARRAY_SIZE(intel_ivbep_unc_p_pe),
76         .type                   = PFM_PMU_TYPE_UNCORE,
77         .num_cntrs              = 4,
78         .num_fixed_cntrs        = 0,
79         .max_encoding           = 2,
80         .pe                     = intel_ivbep_unc_p_pe,
81         .atdesc                 = snbep_unc_mods,
82         .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
83         .pmu_detect             = pfm_intel_ivbep_unc_detect,
84         .get_event_encoding[PFM_OS_NONE] = pfm_intel_snbep_unc_get_encoding,
85          PFMLIB_ENCODE_PERF(pfm_intel_snbep_unc_get_perf_encoding),
86          PFMLIB_OS_DETECT(pfm_intel_x86_perf_detect),
87         .get_event_first        = pfm_intel_x86_get_event_first,
88         .get_event_next         = pfm_intel_x86_get_event_next,
89         .event_is_valid         = pfm_intel_x86_event_is_valid,
90         .validate_table         = pfm_intel_x86_validate_table,
91         .get_event_info         = pfm_intel_x86_get_event_info,
92         .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
93         PFMLIB_VALID_PERF_PATTRS(pfm_intel_snbep_unc_perf_validate_pattrs),
94         .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
95         .can_auto_encode        = pfm_intel_snbep_unc_can_auto_encode,
96         .display_reg            = display_pcu,
97 };