linux/drivers/hwtracing/ptt/hisi_ptt.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Driver for HiSilicon PCIe tune and trace device
 *
 * Copyright (c) 2022 HiSilicon Technologies Co., Ltd.
 * Author: Yicong Yang <[email protected]>
 */

#ifndef _HISI_PTT_H
#define _HISI_PTT_H

#include <linux/bits.h>
#include <linux/cpumask.h>
#include <linux/device.h>
#include <linux/kfifo.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
#include <linux/pci.h>
#include <linux/perf_event.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/workqueue.h>

#define DRV_NAME

/*
 * The definition of the device registers and register fields.
 */
#define HISI_PTT_TUNING_CTRL
#define HISI_PTT_TUNING_CTRL_CODE
#define HISI_PTT_TUNING_CTRL_SUB
#define HISI_PTT_TUNING_DATA
#define HISI_PTT_TUNING_DATA_VAL_MASK
#define HISI_PTT_TRACE_ADDR_SIZE
#define HISI_PTT_TRACE_ADDR_BASE_LO_0
#define HISI_PTT_TRACE_ADDR_BASE_HI_0
#define HISI_PTT_TRACE_ADDR_STRIDE
#define HISI_PTT_TRACE_CTRL
#define HISI_PTT_TRACE_CTRL_EN
#define HISI_PTT_TRACE_CTRL_RST
#define HISI_PTT_TRACE_CTRL_RXTX_SEL
#define HISI_PTT_TRACE_CTRL_TYPE_SEL
#define HISI_PTT_TRACE_CTRL_DATA_FORMAT
#define HISI_PTT_TRACE_CTRL_FILTER_MODE
#define HISI_PTT_TRACE_CTRL_TARGET_SEL
#define HISI_PTT_TRACE_INT_STAT
#define HISI_PTT_TRACE_INT_STAT_MASK
#define HISI_PTT_TRACE_INT_MASK
#define HISI_PTT_TRACE_INT_MASK_ALL
#define HISI_PTT_TUNING_INT_STAT
#define HISI_PTT_TUNING_INT_STAT_MASK
#define HISI_PTT_TRACE_WR_STS
#define HISI_PTT_TRACE_WR_STS_WRITE
#define HISI_PTT_TRACE_WR_STS_BUFFER
#define HISI_PTT_TRACE_STS
#define HISI_PTT_TRACE_IDLE
#define HISI_PTT_DEVICE_RANGE
#define HISI_PTT_DEVICE_RANGE_UPPER
#define HISI_PTT_DEVICE_RANGE_LOWER
#define HISI_PTT_LOCATION
#define HISI_PTT_CORE_ID
#define HISI_PTT_SICL_ID

/* Parameters of PTT trace DMA part. */
#define HISI_PTT_TRACE_DMA_IRQ
#define HISI_PTT_TRACE_BUF_CNT
#define HISI_PTT_TRACE_BUF_SIZE
#define HISI_PTT_TRACE_TOTAL_BUF_SIZE
/* Wait time for hardware DMA to reset */
#define HISI_PTT_RESET_TIMEOUT_US
#define HISI_PTT_RESET_POLL_INTERVAL_US
/* Poll timeout and interval for waiting hardware work to finish */
#define HISI_PTT_WAIT_TUNE_TIMEOUT_US
#define HISI_PTT_WAIT_TRACE_TIMEOUT_US
#define HISI_PTT_WAIT_POLL_INTERVAL_US

/* FIFO size for dynamically updating the PTT trace filter list. */
#define HISI_PTT_FILTER_UPDATE_FIFO_SIZE
/* Delay time for filter updating work */
#define HISI_PTT_WORK_DELAY_MS

#define HISI_PCIE_CORE_PORT_ID(devfn)

/* Definition of the PMU configs */
#define HISI_PTT_PMU_FILTER_IS_PORT
#define HISI_PTT_PMU_FILTER_VAL_MASK
#define HISI_PTT_PMU_DIRECTION_MASK
#define HISI_PTT_PMU_TYPE_MASK
#define HISI_PTT_PMU_FORMAT_MASK

/**
 * struct hisi_ptt_tune_desc - Describe tune event for PTT tune
 * @hisi_ptt:   PTT device this tune event belongs to
 * @name:       name of this event
 * @event_code: code of the event
 */
struct hisi_ptt_tune_desc {};

/**
 * struct hisi_ptt_dma_buffer - Describe a single trace buffer of PTT trace.
 *                              The detail of the data format is described
 *                              in the documentation of PTT device.
 * @dma:   DMA address of this buffer visible to the device
 * @addr:  virtual address of this buffer visible to the cpu
 */
struct hisi_ptt_dma_buffer {};

/**
 * struct hisi_ptt_trace_ctrl - Control and status of PTT trace
 * @trace_buf: array of the trace buffers for holding the trace data.
 *             the length will be HISI_PTT_TRACE_BUF_CNT.
 * @handle:    perf output handle of current trace session
 * @buf_index: the index of current using trace buffer
 * @on_cpu:    current tracing cpu
 * @started:   current trace status, true for started
 * @is_port:   whether we're tracing root port or not
 * @direction: direction of the TLP headers to trace
 * @filter:    filter value for tracing the TLP headers
 * @format:    format of the TLP headers to trace
 * @type:      type of the TLP headers to trace
 */
struct hisi_ptt_trace_ctrl {};

/*
 * sysfs attribute group name for root port filters and requester filters:
 * /sys/devices/hisi_ptt<sicl_id>_<core_id>/root_port_filters
 * and
 * /sys/devices/hisi_ptt<sicl_id>_<core_id>/requester_filters
 */
#define HISI_PTT_RP_FILTERS_GRP_NAME
#define HISI_PTT_REQ_FILTERS_GRP_NAME

/**
 * struct hisi_ptt_filter_desc - Descriptor of the PTT trace filter
 * @attr:    sysfs attribute of this filter
 * @list:    entry of this descriptor in the filter list
 * @is_port: the PCI device of the filter is a Root Port or not
 * @name:    name of this filter, same as the name of the related PCI device
 * @devid:   the PCI device's devid of the filter
 */
struct hisi_ptt_filter_desc {};

/**
 * struct hisi_ptt_filter_update_info - Information for PTT filter updating
 * @is_port:    the PCI device to update is a Root Port or not
 * @is_add:     adding to the filter or not
 * @devid:      the PCI device's devid of the filter
 */
struct hisi_ptt_filter_update_info {};

/**
 * struct hisi_ptt_pmu_buf - Descriptor of the AUX buffer of PTT trace
 * @length:   size of the AUX buffer
 * @nr_pages: number of pages of the AUX buffer
 * @base:     start address of AUX buffer
 * @pos:      position in the AUX buffer to commit traced data
 */
struct hisi_ptt_pmu_buf {};

/**
 * struct hisi_ptt - Per PTT device data
 * @trace_ctrl:   the control information of PTT trace
 * @hisi_ptt_nb:  dynamic filter update notifier
 * @hotplug_node: node for register cpu hotplug event
 * @hisi_ptt_pmu: the pum device of trace
 * @iobase:       base IO address of the device
 * @pdev:         pci_dev of this PTT device
 * @tune_lock:    lock to serialize the tune process
 * @pmu_lock:     lock to serialize the perf process
 * @trace_irq:    interrupt number used by trace
 * @upper_bdf:    the upper BDF range of the PCI devices managed by this PTT device
 * @lower_bdf:    the lower BDF range of the PCI devices managed by this PTT device
 * @port_filters: the filter list of root ports
 * @req_filters:  the filter list of requester ID
 * @filter_lock:  lock to protect the filters
 * @sysfs_inited: whether the filters' sysfs entries has been initialized
 * @port_mask:    port mask of the managed root ports
 * @work:         delayed work for filter updating
 * @filter_update_lock: spinlock to protect the filter update fifo
 * @filter_update_fifo: fifo of the filters waiting to update the filter list
 */
struct hisi_ptt {};

#define to_hisi_ptt(pmu)

#endif /* _HISI_PTT_H */