akaros/user/perfmon/pfmlib_intel_snbep_unc_ha.c
<<
>>
Prefs
   1/*
   2 * pfmlib_intel_snb_unc_ha.c : Intel SandyBridge-EP Home Agent (HA) uncore PMU
   3 *
   4 * Copyright (c) 2012 Google, Inc
   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_snbep_unc_ha_events.h"
  35
  36static void
  37display_ha(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_HA=0x%"PRIx64" event=0x%x umask=0x%x en=%d "
  44                       "inv=%d edge=%d thres=%d] %s\n",
  45                        reg->val,
  46                        reg->com.unc_event,
  47                        reg->com.unc_umask,
  48                        reg->com.unc_en,
  49                        reg->com.unc_inv,
  50                        reg->com.unc_edge,
  51                        reg->com.unc_thres,
  52                        pe[e->event].name);
  53
  54        if (e->count == 1)
  55                return;
  56
  57        f.val = e->codes[1];
  58        __pfm_vbprintf("[UNC_HA_ADDR=0x%"PRIx64" lo_addr=0x%x hi_addr=0x%x]\n",
  59                        f.val,
  60                        f.ha_addr.lo_addr,
  61                        f.ha_addr.hi_addr);
  62
  63        f.val = e->codes[2];
  64        __pfm_vbprintf("[UNC_HA_OPC=0x%"PRIx64" opc=0x%x]\n", f.val, f.ha_opc.opc);
  65}
  66
  67pfmlib_pmu_t intel_snbep_unc_ha_support = {
  68        .desc                   = "Intel Sandy Bridge-EP HA uncore",
  69        .name                   = "snbep_unc_ha",
  70        .perf_name              = "uncore_ha",
  71        .pmu                    = PFM_PMU_INTEL_SNBEP_UNC_HA,
  72        .pme_count              = LIBPFM_ARRAY_SIZE(intel_snbep_unc_h_pe),
  73        .type                   = PFM_PMU_TYPE_UNCORE,
  74        .num_cntrs              = 4,
  75        .num_fixed_cntrs        = 0,
  76        .max_encoding           = 3, /* address matchers */
  77        .pe                     = intel_snbep_unc_h_pe,
  78        .atdesc                 = snbep_unc_mods,
  79        .flags                  = PFMLIB_PMU_FL_RAW_UMASK
  80                                | PFMLIB_PMU_FL_NO_SMPL,
  81        .pmu_detect             = pfm_intel_snbep_unc_detect,
  82        .get_event_encoding[PFM_OS_NONE] = pfm_intel_snbep_unc_get_encoding,
  83         PFMLIB_ENCODE_PERF(pfm_intel_snbep_unc_get_perf_encoding),
  84        .get_event_first        = pfm_intel_x86_get_event_first,
  85        .get_event_next         = pfm_intel_x86_get_event_next,
  86        .event_is_valid         = pfm_intel_x86_event_is_valid,
  87        .validate_table         = pfm_intel_x86_validate_table,
  88        .get_event_info         = pfm_intel_x86_get_event_info,
  89        .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
  90        PFMLIB_VALID_PERF_PATTRS(pfm_intel_snbep_unc_perf_validate_pattrs),
  91        .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
  92        .display_reg            = display_ha,
  93};
  94