akaros/user/perfmon/pfmlib_intel_ivb_unc.c
<<
>>
Prefs
   1/*
   2 * pfmlib_intel_ivb_unc.c : Intel IvyBridge C-Box uncore PMU
   3 *
   4 * Contributed by Stephane Eranian <eranian@gmail.com>
   5 *
   6 * Permission is hereby granted, free of charge, to any person obtaining a copy
   7 * of this software and associated documentation files (the "Software"), to deal
   8 * in the Software without restriction, including without limitation the rights
   9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  10 * of the Software, and to permit persons to whom the Software is furnished to do so,
  11 * subject to the following conditions:
  12 *
  13 * The above copyright notice and this permission notice shall be included in all
  14 * copies or substantial portions of the Software.
  15 *
  16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  17 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  18 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 */
  23/* private headers */
  24#include "pfmlib_priv.h"
  25#include "pfmlib_intel_x86_priv.h"
  26
  27#define INTEL_SNB_UNC_ATTRS \
  28        (_INTEL_X86_ATTR_I|_INTEL_X86_ATTR_E|_INTEL_X86_ATTR_C)
  29
  30/* same event table as SNB */
  31#include "events/intel_snb_unc_events.h"
  32
  33static int
  34pfm_ivb_unc_detect(void *this)
  35{
  36        int ret;
  37
  38        ret = pfm_intel_x86_detect();
  39        if (ret != PFM_SUCCESS)
  40                return ret;
  41
  42        if (pfm_intel_x86_cfg.family != 6)
  43                return PFM_ERR_NOTSUPP;
  44
  45        switch (pfm_intel_x86_cfg.model) {
  46                case 58: /* IvyBridge */
  47                        break;
  48                default:
  49                        return PFM_ERR_NOTSUPP;
  50        }
  51        return PFM_SUCCESS;
  52}
  53
  54#define IVB_UNC_CBOX(n, p) \
  55pfmlib_pmu_t intel_ivb_unc_cbo##n##_support={ \
  56        .desc                   = "Intel Ivy Bridge C-box"#n" uncore", \
  57        .name                   = "ivb_unc_cbo"#n, \
  58        .perf_name              = "uncore_cbox_"#n, \
  59        .pmu                    = PFM_PMU_INTEL_IVB_UNC_CB##n, \
  60        .pme_count              = LIBPFM_ARRAY_SIZE(intel_snb_unc_##p##_pe), \
  61        .type                   = PFM_PMU_TYPE_UNCORE, \
  62        .num_cntrs              = 2, \
  63        .num_fixed_cntrs        = 1, \
  64        .max_encoding           = 1,\
  65        .pe                     = intel_snb_unc_##p##_pe, \
  66        .atdesc                 = intel_x86_mods, \
  67        .flags                  = PFMLIB_PMU_FL_RAW_UMASK\
  68                                | PFMLIB_PMU_FL_NO_SMPL,\
  69        .pmu_detect             = pfm_ivb_unc_detect, \
  70        .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding, \
  71         PFMLIB_ENCODE_PERF(pfm_intel_nhm_unc_get_perf_encoding), \
  72         PFMLIB_OS_DETECT(pfm_intel_x86_perf_detect), \
  73        .get_event_first        = pfm_intel_x86_get_event_first, \
  74        .get_event_next         = pfm_intel_x86_get_event_next, \
  75        .event_is_valid         = pfm_intel_x86_event_is_valid, \
  76        .validate_table         = pfm_intel_x86_validate_table, \
  77        .get_event_info         = pfm_intel_x86_get_event_info, \
  78        .get_event_attr_info    = pfm_intel_x86_get_event_attr_info, \
  79         PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),\
  80        .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,\
  81}
  82
  83IVB_UNC_CBOX(0, cbo0);
  84IVB_UNC_CBOX(1, cbo);
  85IVB_UNC_CBOX(2, cbo);
  86IVB_UNC_CBOX(3, cbo);
  87