Expose through debugfs device telemetry data for QAT GEN4 devices. This allows to gather metrics about the performance and the utilization of a device. In particular, statistics on (1) the utilization of the PCIe channel, (2) address translation, when SVA is enabled and (3) the internal engines for crypto and data compression. If telemetry is supported by the firmware, the driver allocates a DMA region and a circular buffer. When telemetry is enabled, through the `control` attribute in debugfs, the driver sends to the firmware, via the admin interface, the `TL_START` command. This triggers the device to periodically gather telemetry data from hardware registers and write it into the DMA memory region. The device writes into the shared region every second. The driver, every 500ms, snapshots the DMA shared region into the circular buffer. This is then used to compute basic metric (min/max/average) on each counter, every time the `device_data` attribute is queried. Telemetry counters are exposed through debugfs in the folder /sys/kernel/debug/qat_<device>_<BDF>/telemetry. For details, refer to debugfs-driver-qat_telemetry in Documentation/ABI. This patch is based on earlier work done by Wojciech Ziemba. Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Damian Muszynski <damian.muszynski@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
90 lines
2.3 KiB
C
90 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/* Copyright(c) 2023 Intel Corporation */
|
|
|
|
#include <linux/debugfs.h>
|
|
#include "adf_accel_devices.h"
|
|
#include "adf_cfg.h"
|
|
#include "adf_common_drv.h"
|
|
#include "adf_cnv_dbgfs.h"
|
|
#include "adf_dbgfs.h"
|
|
#include "adf_fw_counters.h"
|
|
#include "adf_heartbeat_dbgfs.h"
|
|
#include "adf_pm_dbgfs.h"
|
|
#include "adf_tl_debugfs.h"
|
|
|
|
/**
|
|
* adf_dbgfs_init() - add persistent debugfs entries
|
|
* @accel_dev: Pointer to acceleration device.
|
|
*
|
|
* This function creates debugfs entries that are persistent through a device
|
|
* state change (from up to down or vice versa).
|
|
*/
|
|
void adf_dbgfs_init(struct adf_accel_dev *accel_dev)
|
|
{
|
|
char name[ADF_DEVICE_NAME_LENGTH];
|
|
void *ret;
|
|
|
|
/* Create dev top level debugfs entry */
|
|
snprintf(name, sizeof(name), "%s%s_%s", ADF_DEVICE_NAME_PREFIX,
|
|
accel_dev->hw_device->dev_class->name,
|
|
pci_name(accel_dev->accel_pci_dev.pci_dev));
|
|
|
|
ret = debugfs_create_dir(name, NULL);
|
|
if (IS_ERR_OR_NULL(ret))
|
|
return;
|
|
|
|
accel_dev->debugfs_dir = ret;
|
|
|
|
adf_cfg_dev_dbgfs_add(accel_dev);
|
|
}
|
|
EXPORT_SYMBOL_GPL(adf_dbgfs_init);
|
|
|
|
/**
|
|
* adf_dbgfs_exit() - remove persistent debugfs entries
|
|
* @accel_dev: Pointer to acceleration device.
|
|
*/
|
|
void adf_dbgfs_exit(struct adf_accel_dev *accel_dev)
|
|
{
|
|
adf_cfg_dev_dbgfs_rm(accel_dev);
|
|
debugfs_remove(accel_dev->debugfs_dir);
|
|
}
|
|
EXPORT_SYMBOL_GPL(adf_dbgfs_exit);
|
|
|
|
/**
|
|
* adf_dbgfs_add() - add non-persistent debugfs entries
|
|
* @accel_dev: Pointer to acceleration device.
|
|
*
|
|
* This function creates debugfs entries that are not persistent through
|
|
* a device state change (from up to down or vice versa).
|
|
*/
|
|
void adf_dbgfs_add(struct adf_accel_dev *accel_dev)
|
|
{
|
|
if (!accel_dev->debugfs_dir)
|
|
return;
|
|
|
|
if (!accel_dev->is_vf) {
|
|
adf_fw_counters_dbgfs_add(accel_dev);
|
|
adf_heartbeat_dbgfs_add(accel_dev);
|
|
adf_pm_dbgfs_add(accel_dev);
|
|
adf_cnv_dbgfs_add(accel_dev);
|
|
adf_tl_dbgfs_add(accel_dev);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* adf_dbgfs_rm() - remove non-persistent debugfs entries
|
|
* @accel_dev: Pointer to acceleration device.
|
|
*/
|
|
void adf_dbgfs_rm(struct adf_accel_dev *accel_dev)
|
|
{
|
|
if (!accel_dev->debugfs_dir)
|
|
return;
|
|
|
|
if (!accel_dev->is_vf) {
|
|
adf_tl_dbgfs_rm(accel_dev);
|
|
adf_cnv_dbgfs_rm(accel_dev);
|
|
adf_pm_dbgfs_rm(accel_dev);
|
|
adf_heartbeat_dbgfs_rm(accel_dev);
|
|
adf_fw_counters_dbgfs_rm(accel_dev);
|
|
}
|
|
}
|