Commit 5ee52118 authored by Giovanni Cabiddu's avatar Giovanni Cabiddu Committed by Herbert Xu
Browse files

crypto: qat - expose device state through sysfs for 4xxx



Expose the device state through an attribute in sysfs and allow to
change it. This is to stop and shutdown a QAT device in order to change
its configuration.

The state attribute has been added to a newly created `qat` attribute
group which will contain all _QAT specific_ attributes.

The logic that implements the sysfs entries is part of a new file,
adf_sysfs.c. This exposes an entry point to allow the driver to create
attributes.

The function that creates the sysfs attributes is called from the probe
function of the driver and not in the state machine init function to
allow the change of states even if the device is in the down state.

In order to restore the device configuration between a transition from
down to up, the function that configures the devices has been abstracted
into the HW data structure.

The `state` attribute is only exposed for qat_4xxx devices.

Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Co-developed-by: default avatarTomasz Kowallik <tomaszx.kowalik@intel.com>
Signed-off-by: default avatarTomasz Kowallik <tomaszx.kowalik@intel.com>
Reviewed-by: default avatarAdam Guerin <adam.guerin@intel.com>
Reviewed-by: default avatarFiona Trahe <fiona.trahe@intel.com>
Reviewed-by: default avatarWojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: default avatarVladis Dronov <vdronov@redhat.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent fac76f22
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
What:		/sys/bus/pci/devices/<BDF>/qat/state
Date:		June 2022
KernelVersion:	5.20
Contact:	qat-linux@intel.com
Description:	Reports the current state of the QAT device and allows to
		change it.

		This attribute is RW.

		Returned values:
			up: the device is up and running
			down: the device is down

		Allowed values:
			up: initialize and start the device
			down: stop the device and bring it down

		It is possible to transition the device from up to down only
		if the device is up and vice versa.

		This attribute is only available for qat_4xxx devices.
+1 −0
Original line number Diff line number Diff line
@@ -357,6 +357,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data)
	hw_data->ring_pair_reset = adf_gen4_ring_pair_reset;
	hw_data->enable_pm = adf_gen4_enable_pm;
	hw_data->handle_pm_interrupt = adf_gen4_handle_pm_interrupt;
	hw_data->dev_config = adf_crypto_dev_config;

	adf_gen4_init_hw_csr_ops(&hw_data->csr_ops);
	adf_gen4_init_pf_pfvf_ops(&hw_data->pfvf_ops);
+1 −0
Original line number Diff line number Diff line
@@ -70,5 +70,6 @@ enum icp_qat_4xxx_slice_mask {

void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data);
void adf_clean_hw_data_4xxx(struct adf_hw_device_data *hw_data);
int adf_crypto_dev_config(struct adf_accel_dev *accel_dev);

#endif
+5 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static int adf_cfg_dev_init(struct adf_accel_dev *accel_dev)
	return 0;
}

static int adf_crypto_dev_config(struct adf_accel_dev *accel_dev)
int adf_crypto_dev_config(struct adf_accel_dev *accel_dev)
{
	char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
	int banks = GET_MAX_BANKS(accel_dev);
@@ -289,6 +289,10 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
		goto out_err_disable_aer;
	}

	ret = adf_sysfs_init(accel_dev);
	if (ret)
		goto out_err_disable_aer;

	ret = adf_crypto_dev_config(accel_dev);
	if (ret)
		goto out_err_disable_aer;
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ intel_qat-objs := adf_cfg.o \
	adf_transport.o \
	adf_admin.o \
	adf_hw_arbiter.o \
	adf_sysfs.o \
	adf_gen2_hw_data.o \
	adf_gen4_hw_data.o \
	adf_gen4_pm.o \
Loading