linux/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c

// SPDX-License-Identifier: MIT
/*
 * Copyright © 2023-2024 Intel Corporation
 */

#include <linux/debugfs.h>

#include <drm/drm_print.h>
#include <drm/drm_debugfs.h>

#include "xe_bo.h"
#include "xe_debugfs.h"
#include "xe_device.h"
#include "xe_gt.h"
#include "xe_gt_debugfs.h"
#include "xe_gt_sriov_pf_config.h"
#include "xe_gt_sriov_pf_control.h"
#include "xe_gt_sriov_pf_debugfs.h"
#include "xe_gt_sriov_pf_helpers.h"
#include "xe_gt_sriov_pf_monitor.h"
#include "xe_gt_sriov_pf_policy.h"
#include "xe_gt_sriov_pf_service.h"
#include "xe_pm.h"

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0		# d_inode->i_private = gt
 *      │   ├── pf	# d_inode->i_private = gt
 *      │   ├── vf1	# d_inode->i_private = VFID(1)
 *      :   :
 *      │   ├── vfN	# d_inode->i_private = VFID(N)
 */

static void *extract_priv(struct dentry *d)
{}

static struct xe_gt *extract_gt(struct dentry *d)
{}

static unsigned int extract_vfid(struct dentry *d)
{}

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0
 *      │   ├── pf
 *      │   │   ├── ggtt_available
 *      │   │   ├── ggtt_provisioned
 *      │   │   ├── contexts_provisioned
 *      │   │   ├── doorbells_provisioned
 *      │   │   ├── runtime_registers
 *      │   │   ├── negotiated_versions
 *      │   │   ├── adverse_events
 */

static const struct drm_info_list pf_info[] =;

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0
 *      │   ├── pf
 *      │   │   ├── reset_engine
 *      │   │   ├── sample_period
 *      │   │   ├── sched_if_idle
 */

#define DEFINE_SRIOV_GT_POLICY_DEBUGFS_ATTRIBUTE(POLICY, TYPE, FORMAT)

DEFINE_SRIOV_GT_POLICY_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_POLICY_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_POLICY_DEBUGFS_ATTRIBUTE();

static void pf_add_policy_attrs(struct xe_gt *gt, struct dentry *parent)
{}

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0
 *      │   ├── pf
 *      │   │   ├── ggtt_spare
 *      │   │   ├── lmem_spare
 *      │   │   ├── doorbells_spare
 *      │   │   ├── contexts_spare
 *      │   │   ├── exec_quantum_ms
 *      │   │   ├── preempt_timeout_us
 *      │   ├── vf1
 *      │   │   ├── ggtt_quota
 *      │   │   ├── lmem_quota
 *      │   │   ├── doorbells_quota
 *      │   │   ├── contexts_quota
 *      │   │   ├── exec_quantum_ms
 *      │   │   ├── preempt_timeout_us
 */

#define DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE(CONFIG, TYPE, FORMAT)

DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();
DEFINE_SRIOV_GT_CONFIG_DEBUGFS_ATTRIBUTE();

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0
 *      │   ├── pf
 *      │   │   ├── threshold_cat_error_count
 *      │   │   ├── threshold_doorbell_time_us
 *      │   │   ├── threshold_engine_reset_count
 *      │   │   ├── threshold_guc_time_us
 *      │   │   ├── threshold_irq_time_us
 *      │   │   ├── threshold_page_fault_count
 *      │   ├── vf1
 *      │   │   ├── threshold_cat_error_count
 *      │   │   ├── threshold_doorbell_time_us
 *      │   │   ├── threshold_engine_reset_count
 *      │   │   ├── threshold_guc_time_us
 *      │   │   ├── threshold_irq_time_us
 *      │   │   ├── threshold_page_fault_count
 */

static int set_threshold(void *data, u64 val, enum xe_guc_klv_threshold_index index)
{}

static int get_threshold(void *data, u64 *val, enum xe_guc_klv_threshold_index index)
{}

#define DEFINE_SRIOV_GT_THRESHOLD_DEBUGFS_ATTRIBUTE(THRESHOLD, INDEX)

/* generate all threshold attributes */
#define define_threshold_attribute
MAKE_XE_GUC_KLV_THRESHOLDS_SET()
#undef define_threshold_attribute

static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigned int vfid)
{}

/*
 *      /sys/kernel/debug/dri/0/
 *      ├── gt0
 *      │   ├── vf1
 *      │   │   ├── control { stop, pause, resume }
 */

static const struct {} control_cmds[] =;

static ssize_t control_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
{}

static ssize_t control_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{}

static const struct file_operations control_ops =;

/**
 * xe_gt_sriov_pf_debugfs_register - Register SR-IOV PF specific entries in GT debugfs.
 * @gt: the &xe_gt to register
 * @root: the &dentry that represents the GT directory
 *
 * Register SR-IOV PF entries that are GT related and must be shown under GT debugfs.
 */
void xe_gt_sriov_pf_debugfs_register(struct xe_gt *gt, struct dentry *root)
{}