110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * CDDL HEADER START
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The contents of this file are subject to the terms of the
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Common Development and Distribution License (the "License").
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * You may not use this file except in compliance with the License.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * or http://www.opensolaris.org/os/licensing.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * See the License for the specific language governing permissions
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * and limitations under the License.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * When distributing Covered Code, include this CDDL HEADER in each
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * If applicable, add the following below this CDDL HEADER, with the
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * fields enclosed by brackets "[]" replaced with your own identifying
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * information: Portions Copyright [yyyy] [name of copyright owner]
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * CDDL HEADER END
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Use is subject to license terms.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#pragma ident "%Z%%M% %I% %E% SMI"
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <sys/file.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <sys/hypervisor_api.h>
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz#include <sys/hsvc.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <sys/sunndi.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <fpc.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <fpc-impl.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#include <fpc-impl-4v.h>
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#define PCIE_ROOTNEX_COMPATIBLE_NAME "SUNW,sun4v-pci"
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz#define FPC_MODULE_NAME "fpc"
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz#define FPC_REQ_MAJOR_VER 1
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz#define FPC_REQ_MINOR_VER 0
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartzstatic hsvc_info_t fpc_hsvc = {
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz HSVC_REV_1,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz NULL,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz HSVC_GROUP_FIRE_PERF,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz FPC_REQ_MAJOR_VER,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz FPC_REQ_MINOR_VER,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz FPC_MODULE_NAME
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz};
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartzstatic int hyp_regd_users = 0;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartzstatic uint64_t fpc_sup_minor;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The following typedef is used to represent a
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * 1275 "reg" property of a PCI nexus.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartztypedef struct nexus_regspec {
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t phys_addr;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t size;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz} nexus_regspec_t;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzstatic uint64_t counter_select_index[] = {
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_JBC_SEL,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_IMU_SEL,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_MMU_SEL,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_TLU_SEL,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_LNK_SEL
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz};
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The following event and offset arrays is organized by grouping in major
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * order the fire_perfcnt_t register types, and in minor order the register
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * numbers within that type.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * This table maps the above order into the hypervisor interface register
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * indices.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzstatic uint64_t counter_reg_index[] = {
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_JBC_CNT0,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_JBC_CNT1,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_IMU_CNT0,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_IMU_CNT1,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_MMU_CNT0,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_MMU_CNT1,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_TLU_CNT0,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_TLU_CNT1,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_TLU_CNT2,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_LNK_CNT1,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz HVIO_FIRE_PERFREG_PCIE_LNK_CNT2
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz};
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz/* Called by _init to determine if it is OK to install driver. */
0ad689d678ef901f32945172f48ddc7b16dde50dschwartzint
0ad689d678ef901f32945172f48ddc7b16dde50dschwartzfpc_platform_check()
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz{
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz int regstat;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz if ((regstat = hsvc_register(&fpc_hsvc, &fpc_sup_minor)) == SUCCESS) {
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz (void) hsvc_unregister(&fpc_hsvc);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz }
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz fpc_sup_minor = 0;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz return (regstat);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz}
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz/* Called during attach to do module-wide initialization. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzint
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_platform_module_init(dev_info_t *dip)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzint
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_platform_node_init(dev_info_t *dip, int *avail)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz nexus_regspec_t *rp;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint_t reglen;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz devhandle_t dev_hdl;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz int regstat;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz int index;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz boolean_t is_root_pcie_nexus;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t dummy_data;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz char *name = NULL;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz boolean_t jbus_regs_avail;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz boolean_t pcie_regs_avail;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz DDI_PROP_DONTPASS, "compatible", &name) != DDI_PROP_SUCCESS)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz is_root_pcie_nexus = (strcmp(name, PCIE_ROOTNEX_COMPATIBLE_NAME) == 0);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz ddi_prop_free(name);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (!is_root_pcie_nexus)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dip,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz DDI_PROP_DONTPASS, "reg", (uchar_t **)&rp, &reglen) !=
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz DDI_PROP_SUCCESS)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_FAILURE);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz /*
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Initilize device handle. The device handle uniquely
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * identifies a SUN4V device. It consists of the lower 28-bits
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * of the hi-cell of the first entry of the SUN4V device's
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * "reg" property as defined by the SUN4V Bus Binding to Open
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Firmware.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz dev_hdl = (devhandle_t)((rp->phys_addr >> 32) & DEVHDLE_MASK);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz ddi_prop_free(rp);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz /*
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * If this is the first time through here, negotiate with hypervisor
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * that it has the services needed to operate. Don't do this in _init
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * since we may want to modload the driver without attaching,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * for debugging purposes.
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz *
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * Note that this is another way of weeding out unsupported platforms
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz */
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz if (hyp_regd_users == 0) {
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz regstat = hsvc_register(&fpc_hsvc, &fpc_sup_minor);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz if (regstat != SUCCESS) {
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz /*
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * Fail silently since we don't want to print an error
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * on future platforms which don't support this driver.
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz */
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz return (DDI_FAILURE);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz }
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz }
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz hyp_regd_users++;
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz /* See which register sets are usable from this node. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz jbus_regs_avail = (fpc_event_io(
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (fire_perfreg_handle_t)dev_hdl, jbc, &dummy_data, IS_READ) ==
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz pcie_regs_avail = (fpc_event_io(
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (fire_perfreg_handle_t)dev_hdl, imu, &dummy_data, IS_READ) ==
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz /* Nothing usable at this node. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if ((!jbus_regs_avail) && (!pcie_regs_avail))
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz fpc_common_node_setup(dip, &index);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (pcie_regs_avail)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *avail |=
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz ((index == 0) ? PCIE_A_REGS_AVAIL : PCIE_B_REGS_AVAIL);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (jbus_regs_avail) {
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz *avail |= JBUS_REGS_AVAIL;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (index != 0)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz cmn_err(CE_WARN,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz "fpc: JBUS regs available on device idx %d!\n",
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz index);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz }
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (void) fpc_set_platform_data_by_number(index, (void *)dev_hdl);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (DDI_SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzvoid
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_platform_node_fini(void *arg)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz if (--hyp_regd_users == 0)
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz (void) hsvc_unregister(&fpc_hsvc);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzvoid
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_platform_module_fini(dev_info_t *dip)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfire_perfreg_handle_t
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_get_perfreg_handle(int devnum)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz void *platform_specific_data;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if ((platform_specific_data =
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz fpc_get_platform_data_by_number(devnum)) == NULL)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return ((fire_perfreg_handle_t)-1);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz else
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return ((fire_perfreg_handle_t)platform_specific_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzint
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_free_counter_handle(fire_perfreg_handle_t handle)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (SUCCESS);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzstatic int
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_hv_perfreg_io(fire_perfreg_handle_t handle, uint64_t hv_if_index,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t *reg_data, boolean_t is_write)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz int rval;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz devhandle_t dev_hdl = (devhandle_t)handle;
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz if (is_write)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz rval = fpc_set_fire_perfreg(dev_hdl, hv_if_index, *reg_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz else
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz rval = fpc_get_fire_perfreg(dev_hdl, hv_if_index, reg_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return ((rval == H_EOK) ? SUCCESS : EIO);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzint
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_event_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t *reg_data, boolean_t is_write)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t hv_if_index = counter_select_index[group];
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (fpc_hv_perfreg_io(handle, hv_if_index, reg_data, is_write));
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzint
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_counter_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz int counter_index, uint64_t *reg_data, boolean_t is_write)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz{
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t hv_if_index = counter_reg_index[counter_index];
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (fpc_hv_perfreg_io(handle, hv_if_index, reg_data, is_write));
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz}