Commit f6e326b7 authored by Damian Muszynski's avatar Damian Muszynski Committed by Aichun Shi
Browse files

crypto: qat - add heartbeat error simulator

mainline inclusion
from mainline-v6.9-rc1
commit e2b67859ab6efd4458bda1baaee20331a367d995
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9A5BW
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2b67859ab6efd4458bda1baaee20331a367d995



-------------------------------------

Add a mechanism that allows to inject a heartbeat error for testing
purposes.
A new attribute `inject_error` is added to debugfs for each QAT device.
Upon a write on this attribute, the driver will inject an error on the
device which can then be detected by the heartbeat feature.
Errors are breaking the device functionality thus they require a
device reset in order to be recovered.

This functionality is not compiled by default, to enable it
CRYPTO_DEV_QAT_ERROR_INJECTION must be set.

Intel-SIG: commit e2b67859ab6e crypto: qat - add heartbeat error simulator
Backport to support QAT in-tree driver

Signed-off-by: default avatarDamian Muszynski <damian.muszynski@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: default avatarLucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
Reviewed-by: default avatarAhsan Atta <ahsan.atta@intel.com>
Reviewed-by: default avatarMarkas Rapoportas <markas.rapoportas@intel.com>
Signed-off-by: default avatarMun Chun Yep <mun.chun.yep@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
[ Aichun Shi: amend commit log ]
Signed-off-by: default avatarAichun Shi <aichun.shi@intel.com>
parent ab2cca46
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -81,3 +81,29 @@ Description: (RO) Read returns, for each Acceleration Engine (AE), the number
			<N>: Number of Compress and Verify (CnV) errors and type
			     of the last CnV error detected by Acceleration
			     Engine N.

What:		/sys/kernel/debug/qat_<device>_<BDF>/heartbeat/inject_error
Date:		March 2024
KernelVersion:	6.8
Contact:	qat-linux@intel.com
Description:	(WO) Write to inject an error that simulates an heartbeat
		failure. This is to be used for testing purposes.

		After writing this file, the driver stops arbitration on a
		random engine and disables the fetching of heartbeat counters.
		If a workload is running on the device, a job submitted to the
		accelerator might not get a response and a read of the
		`heartbeat/status` attribute might report -1, i.e. device
		unresponsive.
		The error is unrecoverable thus the device must be restarted to
		restore its functionality.

		This attribute is available only when the kernel is built with
		CONFIG_CRYPTO_DEV_QAT_ERROR_INJECTION=y.

		A write of 1 enables error injection.

		The following example shows how to enable error injection::

			# cd /sys/kernel/debug/qat_<device>_<BDF>
			# echo 1 > heartbeat/inject_error
+14 −0
Original line number Diff line number Diff line
@@ -106,3 +106,17 @@ config CRYPTO_DEV_QAT_C62XVF

	  To compile this as a module, choose M here: the module
	  will be called qat_c62xvf.

config CRYPTO_DEV_QAT_ERROR_INJECTION
	bool "Support for Intel(R) QAT Devices Heartbeat Error Injection"
	depends on CRYPTO_DEV_QAT
	depends on DEBUG_FS
	help
	  Enables a mechanism that allows to inject a heartbeat error on
	  Intel(R) QuickAssist devices for testing purposes.

	  This is intended for developer use only.
	  If unsure, say N.

	  This functionality is available via debugfs entry of the Intel(R)
	  QuickAssist device
+2 −0
Original line number Diff line number Diff line
@@ -53,3 +53,5 @@ intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_vf_isr.o adf_pfvf_utils.o \
			       adf_pfvf_pf_msg.o adf_pfvf_pf_proto.o \
			       adf_pfvf_vf_msg.o adf_pfvf_vf_proto.o \
			       adf_gen2_pfvf.o adf_gen4_pfvf.o

intel_qat-$(CONFIG_CRYPTO_DEV_QAT_ERROR_INJECTION) += adf_heartbeat_inject.o
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ void adf_exit_aer(void);
int adf_init_arb(struct adf_accel_dev *accel_dev);
void adf_exit_arb(struct adf_accel_dev *accel_dev);
void adf_update_ring_arb(struct adf_etr_ring_data *ring);
int adf_disable_arb_thd(struct adf_accel_dev *accel_dev, u32 ae, u32 thr);

int adf_dev_get(struct adf_accel_dev *accel_dev);
void adf_dev_put(struct adf_accel_dev *accel_dev);
+0 −6
Original line number Diff line number Diff line
@@ -23,12 +23,6 @@

#define ADF_HB_EMPTY_SIG 0xA5A5A5A5

/* Heartbeat counter pair */
struct hb_cnt_pair {
	__u16 resp_heartbeat_cnt;
	__u16 req_heartbeat_cnt;
};

static int adf_hb_check_polling_freq(struct adf_accel_dev *accel_dev)
{
	u64 curr_time = adf_clock_get_current_time();
Loading