crypto: qat - add support for device telemetry
authorLucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
Fri, 22 Dec 2023 10:35:07 +0000 (11:35 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 29 Dec 2023 03:25:55 +0000 (11:25 +0800)
commit69e7649f7cc2aaa7889174456d39319a623c1a18
treeb1731c39919bcd94d3d1beba2c892a1b45508551
parent7f06679dd54a331d750e5d6f6f04a9df2eba72ff
crypto: qat - add support for device telemetry

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>
13 files changed:
Documentation/ABI/testing/debugfs-driver-qat_telemetry [new file with mode: 0644]
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
drivers/crypto/intel/qat/qat_common/Makefile
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h
drivers/crypto/intel/qat/qat_common/adf_dbgfs.c
drivers/crypto/intel/qat/qat_common/adf_gen4_tl.c [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_gen4_tl.h [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_init.c
drivers/crypto/intel/qat/qat_common/adf_telemetry.c [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_telemetry.h [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.h [new file with mode: 0644]