akaros/user/perfmon/pfmlib_intel_ivbep_unc_cbo.c
<<
>>
Prefs
   1/*
   2 * pfmlib_intel_ivbep_unc_cbo.c : Intel IvyBridge-EP C-Box 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_cbo_events.h"
  35
  36static void
  37display_cbo(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_CBO=0x%"PRIx64" event=0x%x umask=0x%x en=%d "
  44                       "inv=%d edge=%d thres=%d tid_en=%d] %s\n",
  45                        reg->val,
  46                        reg->cbo.unc_event,
  47                        reg->cbo.unc_umask,
  48                        reg->cbo.unc_en,
  49                        reg->cbo.unc_inv,
  50                        reg->cbo.unc_edge,
  51                        reg->cbo.unc_thres,
  52                        reg->cbo.unc_tid,
  53                        pe[e->event].name);
  54
  55        if (e->count == 1)
  56                return;
  57
  58        f.val = e->codes[1];
  59
  60        __pfm_vbprintf("[UNC_CBOX_FILTER0=0x%"PRIx64" tid=%d core=0x%x"
  61                       " state=0x%x]\n",
  62                        f.val,
  63                        f.ivbep_cbo_filt0.tid,
  64                        f.ivbep_cbo_filt0.cid,
  65                        f.ivbep_cbo_filt0.state);
  66
  67        if (e->count == 2)
  68                return;
  69
  70        f.val = e->codes[2];
  71
  72        __pfm_vbprintf("[UNC_CBOX_FILTER1=0x%"PRIx64" nid=%d opc=0x%x"
  73                       " nc=0x%x isoc=0x%x]\n",
  74                        f.val,
  75                        f.ivbep_cbo_filt1.nid,
  76                        f.ivbep_cbo_filt1.opc,
  77                        f.ivbep_cbo_filt1.nc,
  78                        f.ivbep_cbo_filt1.isoc);
  79}
  80
  81#define DEFINE_C_BOX(n) \
  82pfmlib_pmu_t intel_ivbep_unc_cb##n##_support = {\
  83        .desc                   = "Intel Ivy Bridge-EP C-Box "#n" uncore",\
  84        .name                   = "ivbep_unc_cbo"#n,\
  85        .perf_name              = "uncore_cbox_"#n,\
  86        .pmu                    = PFM_PMU_INTEL_IVBEP_UNC_CB##n,\
  87        .pme_count              = LIBPFM_ARRAY_SIZE(intel_ivbep_unc_c_pe),\
  88        .type                   = PFM_PMU_TYPE_UNCORE,\
  89        .num_cntrs              = 4,\
  90        .num_fixed_cntrs        = 0,\
  91        .max_encoding           = 2,\
  92        .pe                     = intel_ivbep_unc_c_pe,\
  93        .atdesc                 = snbep_unc_mods,\
  94        .flags                  = PFMLIB_PMU_FL_RAW_UMASK|INTEL_PMU_FL_UNC_CBO,\
  95        .pmu_detect             = pfm_intel_ivbep_unc_detect,\
  96        .get_event_encoding[PFM_OS_NONE] = pfm_intel_snbep_unc_get_encoding,\
  97         PFMLIB_ENCODE_PERF(pfm_intel_snbep_unc_get_perf_encoding),\
  98         PFMLIB_OS_DETECT(pfm_intel_x86_perf_detect), \
  99        .get_event_first        = pfm_intel_x86_get_event_first,\
 100        .get_event_next         = pfm_intel_x86_get_event_next,\
 101        .event_is_valid         = pfm_intel_x86_event_is_valid,\
 102        .validate_table         = pfm_intel_x86_validate_table,\
 103        .get_event_info         = pfm_intel_x86_get_event_info,\
 104        .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,\
 105        PFMLIB_VALID_PERF_PATTRS(pfm_intel_snbep_unc_perf_validate_pattrs),\
 106        .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,\
 107        .can_auto_encode        = pfm_intel_x86_can_auto_encode, \
 108        .display_reg            = display_cbo,\
 109}
 110
 111DEFINE_C_BOX(0);
 112DEFINE_C_BOX(1);
 113DEFINE_C_BOX(2);
 114DEFINE_C_BOX(3);
 115DEFINE_C_BOX(4);
 116DEFINE_C_BOX(5);
 117DEFINE_C_BOX(6);
 118DEFINE_C_BOX(7);
 119DEFINE_C_BOX(8);
 120DEFINE_C_BOX(9);
 121DEFINE_C_BOX(10);
 122DEFINE_C_BOX(11);
 123DEFINE_C_BOX(12);
 124DEFINE_C_BOX(13);
 125DEFINE_C_BOX(14);
 126