linux/drivers/fpga/dfl-fme-perf.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Driver for FPGA Management Engine (FME) Global Performance Reporting
 *
 * Copyright 2019 Intel Corporation, Inc.
 *
 * Authors:
 *   Kang Luwei <[email protected]>
 *   Xiao Guangrong <[email protected]>
 *   Wu Hao <[email protected]>
 *   Xu Yilun <[email protected]>
 *   Joseph Grecco <[email protected]>
 *   Enno Luebbers <[email protected]>
 *   Tim Whisonant <[email protected]>
 *   Ananda Ravuri <[email protected]>
 *   Mitchel, Henry <[email protected]>
 */

#include <linux/perf_event.h>
#include "dfl.h"
#include "dfl-fme.h"

/*
 * Performance Counter Registers for Cache.
 *
 * Cache Events are listed below as CACHE_EVNT_*.
 */
#define CACHE_CTRL
#define CACHE_RESET_CNTR
#define CACHE_FREEZE_CNTR
#define CACHE_CTRL_EVNT
#define CACHE_EVNT_RD_HIT
#define CACHE_EVNT_WR_HIT
#define CACHE_EVNT_RD_MISS
#define CACHE_EVNT_WR_MISS
#define CACHE_EVNT_RSVD
#define CACHE_EVNT_HOLD_REQ
#define CACHE_EVNT_DATA_WR_PORT_CONTEN
#define CACHE_EVNT_TAG_WR_PORT_CONTEN
#define CACHE_EVNT_TX_REQ_STALL
#define CACHE_EVNT_RX_REQ_STALL
#define CACHE_EVNT_EVICTIONS
#define CACHE_EVNT_MAX
#define CACHE_CHANNEL_SEL
#define CACHE_CHANNEL_RD
#define CACHE_CHANNEL_WR
#define CACHE_CNTR0
#define CACHE_CNTR1
#define CACHE_CNTR_EVNT_CNTR
#define CACHE_CNTR_EVNT

/*
 * Performance Counter Registers for Fabric.
 *
 * Fabric Events are listed below as FAB_EVNT_*
 */
#define FAB_CTRL
#define FAB_RESET_CNTR
#define FAB_FREEZE_CNTR
#define FAB_CTRL_EVNT
#define FAB_EVNT_PCIE0_RD
#define FAB_EVNT_PCIE0_WR
#define FAB_EVNT_PCIE1_RD
#define FAB_EVNT_PCIE1_WR
#define FAB_EVNT_UPI_RD
#define FAB_EVNT_UPI_WR
#define FAB_EVNT_MMIO_RD
#define FAB_EVNT_MMIO_WR
#define FAB_EVNT_MAX
#define FAB_PORT_ID
#define FAB_PORT_FILTER
#define FAB_PORT_FILTER_DISABLE
#define FAB_PORT_FILTER_ENABLE
#define FAB_CNTR
#define FAB_CNTR_EVNT_CNTR
#define FAB_CNTR_EVNT

/*
 * Performance Counter Registers for Clock.
 *
 * Clock Counter can't be reset or frozen by SW.
 */
#define CLK_CNTR
#define BASIC_EVNT_CLK
#define BASIC_EVNT_MAX

/*
 * Performance Counter Registers for IOMMU / VT-D.
 *
 * VT-D Events are listed below as VTD_EVNT_* and VTD_SIP_EVNT_*
 */
#define VTD_CTRL
#define VTD_RESET_CNTR
#define VTD_FREEZE_CNTR
#define VTD_CTRL_EVNT
#define VTD_EVNT_AFU_MEM_RD_TRANS
#define VTD_EVNT_AFU_MEM_WR_TRANS
#define VTD_EVNT_AFU_DEVTLB_RD_HIT
#define VTD_EVNT_AFU_DEVTLB_WR_HIT
#define VTD_EVNT_DEVTLB_4K_FILL
#define VTD_EVNT_DEVTLB_2M_FILL
#define VTD_EVNT_DEVTLB_1G_FILL
#define VTD_EVNT_MAX
#define VTD_CNTR
#define VTD_CNTR_EVNT_CNTR
#define VTD_CNTR_EVNT

#define VTD_SIP_CTRL
#define VTD_SIP_RESET_CNTR
#define VTD_SIP_FREEZE_CNTR
#define VTD_SIP_CTRL_EVNT
#define VTD_SIP_EVNT_IOTLB_4K_HIT
#define VTD_SIP_EVNT_IOTLB_2M_HIT
#define VTD_SIP_EVNT_IOTLB_1G_HIT
#define VTD_SIP_EVNT_SLPWC_L3_HIT
#define VTD_SIP_EVNT_SLPWC_L4_HIT
#define VTD_SIP_EVNT_RCC_HIT
#define VTD_SIP_EVNT_IOTLB_4K_MISS
#define VTD_SIP_EVNT_IOTLB_2M_MISS
#define VTD_SIP_EVNT_IOTLB_1G_MISS
#define VTD_SIP_EVNT_SLPWC_L3_MISS
#define VTD_SIP_EVNT_SLPWC_L4_MISS
#define VTD_SIP_EVNT_RCC_MISS
#define VTD_SIP_EVNT_MAX
#define VTD_SIP_CNTR
#define VTD_SIP_CNTR_EVNT_CNTR
#define VTD_SIP_CNTR_EVNT

#define PERF_TIMEOUT

#define PERF_MAX_PORT_NUM

/**
 * struct fme_perf_priv - priv data structure for fme perf driver
 *
 * @dev: parent device.
 * @ioaddr: mapped base address of mmio region.
 * @pmu: pmu data structure for fme perf counters.
 * @id: id of this fme performance report private feature.
 * @fab_users: current user number on fabric counters.
 * @fab_port_id: used to indicate current working mode of fabric counters.
 * @fab_lock: lock to protect fabric counters working mode.
 * @cpu: active CPU to which the PMU is bound for accesses.
 * @node: node for CPU hotplug notifier link.
 * @cpuhp_state: state for CPU hotplug notification;
 */
struct fme_perf_priv {};

/**
 * struct fme_perf_event_ops - callbacks for fme perf events
 *
 * @event_init: callback invoked during event init.
 * @event_destroy: callback invoked during event destroy.
 * @read_counter: callback to read hardware counters.
 */
struct fme_perf_event_ops {};

#define to_fme_perf_priv(_pmu)

static ssize_t cpumask_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(cpumask);

static struct attribute *fme_perf_cpumask_attrs[] =;

static const struct attribute_group fme_perf_cpumask_group =;

#define FME_EVENT_MASK
#define FME_EVENT_SHIFT
#define FME_EVTYPE_MASK
#define FME_EVTYPE_SHIFT
#define FME_EVTYPE_BASIC
#define FME_EVTYPE_CACHE
#define FME_EVTYPE_FABRIC
#define FME_EVTYPE_VTD
#define FME_EVTYPE_VTD_SIP
#define FME_EVTYPE_MAX
#define FME_PORTID_MASK
#define FME_PORTID_SHIFT
#define FME_PORTID_ROOT

#define get_event(_config)
#define get_evtype(_config)
#define get_portid(_config)

PMU_FORMAT_ATTR();
PMU_FORMAT_ATTR();
PMU_FORMAT_ATTR();

static struct attribute *fme_perf_format_attrs[] =;

static const struct attribute_group fme_perf_format_group =;

/*
 * There are no default events, but we need to create
 * "events" group (with empty attrs) before updating
 * it with detected events (using pmu->attr_update).
 */
static struct attribute *fme_perf_events_attrs_empty[] =;

static const struct attribute_group fme_perf_events_group =;

static const struct attribute_group *fme_perf_groups[] =;

static bool is_portid_root(u32 portid)
{}

static bool is_portid_port(u32 portid)
{}

static bool is_portid_root_or_port(u32 portid)
{}

static u64 fme_read_perf_cntr_reg(void __iomem *addr)
{}

static int basic_event_init(struct fme_perf_priv *priv, u32 event, u32 portid)
{}

static u64 basic_read_event_counter(struct fme_perf_priv *priv,
				    u32 event, u32 portid)
{}

static int cache_event_init(struct fme_perf_priv *priv, u32 event, u32 portid)
{}

static u64 cache_read_event_counter(struct fme_perf_priv *priv,
				    u32 event, u32 portid)
{}

static bool is_fabric_event_supported(struct fme_perf_priv *priv, u32 event,
				      u32 portid)
{}

static int fabric_event_init(struct fme_perf_priv *priv, u32 event, u32 portid)
{}

static void fabric_event_destroy(struct fme_perf_priv *priv, u32 event,
				 u32 portid)
{}

static u64 fabric_read_event_counter(struct fme_perf_priv *priv, u32 event,
				     u32 portid)
{}

static int vtd_event_init(struct fme_perf_priv *priv, u32 event, u32 portid)
{}

static u64 vtd_read_event_counter(struct fme_perf_priv *priv, u32 event,
				  u32 portid)
{}

static int vtd_sip_event_init(struct fme_perf_priv *priv, u32 event, u32 portid)
{}

static u64 vtd_sip_read_event_counter(struct fme_perf_priv *priv, u32 event,
				      u32 portid)
{}

static struct fme_perf_event_ops fme_perf_event_ops[] =;

static ssize_t fme_perf_event_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

#define FME_EVENT_ATTR(_name)

#define FME_PORT_EVENT_CONFIG(_event, _type)

#define FME_EVENT_CONFIG(_event, _type)

/* FME Perf Basic Events */
#define FME_EVENT_BASIC(_name, _event)

FME_EVENT_BASIC();

static struct attribute *fme_perf_basic_events_attrs[] =;

static const struct attribute_group fme_perf_basic_events_group =;

/* FME Perf Cache Events */
#define FME_EVENT_CACHE(_name, _event)

FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();
FME_EVENT_CACHE();

static struct attribute *fme_perf_cache_events_attrs[] =;

static umode_t fme_perf_events_visible(struct kobject *kobj,
				       struct attribute *attr, int n)
{}

static const struct attribute_group fme_perf_cache_events_group =;

/* FME Perf Fabric Events */
#define FME_EVENT_FABRIC(_name, _event)

#define FME_EVENT_FABRIC_PORT(_name, _event)

FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();
FME_EVENT_FABRIC();

FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();
FME_EVENT_FABRIC_PORT();

static struct attribute *fme_perf_fabric_events_attrs[] =;

static umode_t fme_perf_fabric_events_visible(struct kobject *kobj,
					      struct attribute *attr, int n)
{}

static const struct attribute_group fme_perf_fabric_events_group =;

/* FME Perf VTD Events */
#define FME_EVENT_VTD_PORT(_name, _event)

FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();
FME_EVENT_VTD_PORT();

static struct attribute *fme_perf_vtd_events_attrs[] =;

static const struct attribute_group fme_perf_vtd_events_group =;

/* FME Perf VTD SIP Events */
#define FME_EVENT_VTD_SIP(_name, _event)

FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();
FME_EVENT_VTD_SIP();

static struct attribute *fme_perf_vtd_sip_events_attrs[] =;

static const struct attribute_group fme_perf_vtd_sip_events_group =;

static const struct attribute_group *fme_perf_events_groups[] =;

static struct fme_perf_event_ops *get_event_ops(u32 evtype)
{}

static void fme_perf_event_destroy(struct perf_event *event)
{}

static int fme_perf_event_init(struct perf_event *event)
{}

static void fme_perf_event_update(struct perf_event *event)
{}

static void fme_perf_event_start(struct perf_event *event, int flags)
{}

static void fme_perf_event_stop(struct perf_event *event, int flags)
{}

static int fme_perf_event_add(struct perf_event *event, int flags)
{}

static void fme_perf_event_del(struct perf_event *event, int flags)
{}

static void fme_perf_event_read(struct perf_event *event)
{}

static void fme_perf_setup_hardware(struct fme_perf_priv *priv)
{}

static int fme_perf_pmu_register(struct platform_device *pdev,
				 struct fme_perf_priv *priv)
{}

static void fme_perf_pmu_unregister(struct fme_perf_priv *priv)
{}

static int fme_perf_offline_cpu(unsigned int cpu, struct hlist_node *node)
{}

static int fme_perf_init(struct platform_device *pdev,
			 struct dfl_feature *feature)
{}

static void fme_perf_uinit(struct platform_device *pdev,
			   struct dfl_feature *feature)
{}

const struct dfl_feature_id fme_perf_id_table[] =;

const struct dfl_feature_ops fme_perf_ops =;