From 5ee52118ac1481dd8a8f7e6a9bfe6ee05ac6ec92 Mon Sep 17 00:00:00 2001 From: Giovanni Cabiddu Date: Mon, 27 Jun 2022 09:36:49 +0100 Subject: 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: Giovanni Cabiddu Co-developed-by: Tomasz Kowallik Signed-off-by: Tomasz Kowallik Reviewed-by: Adam Guerin Reviewed-by: Fiona Trahe Reviewed-by: Wojciech Ziemba Reviewed-by: Vladis Dronov Signed-off-by: Herbert Xu --- Documentation/ABI/testing/sysfs-driver-qat | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-qat (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat new file mode 100644 index 000000000000..769b09cefa89 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -0,0 +1,21 @@ +What: /sys/bus/pci/devices//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. -- cgit From d4cfb144f60551d80732c93c892fe76fc8df860d Mon Sep 17 00:00:00 2001 From: Giovanni Cabiddu Date: Mon, 27 Jun 2022 09:36:52 +0100 Subject: crypto: qat - expose device config through sysfs for 4xxx qat_4xxx devices can be configured to allow either crypto or compression operations. At the moment, devices are configured statically according to the following rule: - odd numbered devices assigned to compression services - even numbered devices assigned to crypto services Expose the sysfs attribute /sys/bus/pci/devices//qat/cfg_services to allow to detect the configuration of a device and to change it. The `cfg_service` attribute is only exposed for qat_4xxx devices and it is limited to two configurations: (1) "sym;asym" for crypto services and "dc" for compression services. Signed-off-by: Giovanni Cabiddu Co-developed-by: Tomasz Kowallik Signed-off-by: Tomasz Kowallik Reviewed-by: Adam Guerin Reviewed-by: Fiona Trahe Reviewed-by: Wojciech Ziemba Reviewed-by: Vladis Dronov Signed-off-by: Herbert Xu --- Documentation/ABI/testing/sysfs-driver-qat | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index 769b09cefa89..a600531e9562 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -19,3 +19,42 @@ Description: Reports the current state of the QAT device and allows to if the device is up and vice versa. This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat/cfg_services +Date: June 2022 +KernelVersion: 5.20 +Contact: qat-linux@intel.com +Description: Reports the current configuration of the QAT device and allows + to change it. + + This attribute is RW. + + Returned values: + sym;asym: the device is configured for running + crypto services + dc: the device is configured for running + compression services + + Allowed values: + sym;asym: configure the device for running + crypto services + dc: configure the device for running + compression services + + It is possible to set the configuration only if the device + is in the `down` state (see /sys/bus/pci/devices//qat/state) + + The following example shows how to change the configuration of + a device configured for running crypto services in order to + run data compression: + # cat /sys/bus/pci/devices//qat/state + up + # cat /sys/bus/pci/devices//qat/cfg_services + sym;asym + # echo down > /sys/bus/pci/devices//qat/state + # echo dc > /sys/bus/pci/devices//qat/cfg_services + # echo up > /sys/bus/pci/devices//qat/state + # cat /sys/bus/pci/devices//qat/cfg_services + dc + + This attribute is only available for qat_4xxx devices. -- cgit From 19cdbdb7cda0cb4948dfaab613d8b4f63c88a53e Mon Sep 17 00:00:00 2001 From: Bagas Sanjaya Date: Wed, 13 Jul 2022 15:56:27 +0700 Subject: Documentation: qat: Use code block for qat sysfs example kernel test robot and Stephen Rothwell reported htmldocs warning: Documentation/ABI/testing/sysfs-driver-qat:24: WARNING: Unexpected indentation. The warning isn't caused by Date: field pointed by the warning, but rather by sysfs example that isn't in literal code block. Add the code block marker. Link: https://lore.kernel.org/linux-next/20220711204932.333379b4@canb.auug.org.au/ Link: https://lore.kernel.org/linux-doc/202207090803.TEGI95qw-lkp@intel.com/ Reported-by: kernel test robot Reported-by: Stephen Rothwell Fixes: d4cfb144f60551 ("crypto: qat - expose device config through sysfs for 4xxx") Acked-by: Giovanni Cabiddu Cc: Wojciech Ziemba Cc: Adam Guerin Cc: Fiona Trahe Cc: Herbert Xu Cc: Vladis Dronov Cc: Tomasz Kowallik Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Bagas Sanjaya Acked-by: Vladis Dronov Signed-off-by: Herbert Xu --- Documentation/ABI/testing/sysfs-driver-qat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index a600531e9562..43e081ec22cc 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -46,7 +46,8 @@ Description: Reports the current configuration of the QAT device and allows The following example shows how to change the configuration of a device configured for running crypto services in order to - run data compression: + run data compression:: + # cat /sys/bus/pci/devices//qat/state up # cat /sys/bus/pci/devices//qat/cfg_services -- cgit From 1b466b8cbfd8321408bb0792b241a2b9222aed62 Mon Sep 17 00:00:00 2001 From: Bagas Sanjaya Date: Wed, 13 Jul 2022 15:56:28 +0700 Subject: Documentation: qat: rewrite description The sysfs description contains redundancy on returned and allowed values list, due to the described sysfs is read-write. Rewrite. Acked-by: Giovanni Cabiddu Cc: Adam Guerin Cc: Tomasz Kowallik Cc: Giovanni Cabiddu Cc: Wojciech Ziemba Cc: Fiona Trahe Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Bagas Sanjaya Signed-off-by: Herbert Xu --- Documentation/ABI/testing/sysfs-driver-qat | 38 ++++++++++-------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'Documentation/ABI') diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index 43e081ec22cc..185f81a2aab3 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -2,18 +2,14 @@ What: /sys/bus/pci/devices//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. +Description: (RW) Reports the current state of the QAT device. Write to + the file to start or stop the device. - This attribute is RW. + The values are: - Returned values: - up: the device is up and running - down: the device is down + * 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. @@ -24,22 +20,14 @@ What: /sys/bus/pci/devices//qat/cfg_services Date: June 2022 KernelVersion: 5.20 Contact: qat-linux@intel.com -Description: Reports the current configuration of the QAT device and allows - to change it. - - This attribute is RW. - - Returned values: - sym;asym: the device is configured for running - crypto services - dc: the device is configured for running - compression services - - Allowed values: - sym;asym: configure the device for running - crypto services - dc: configure the device for running - compression services +Description: (RW) Reports the current configuration of the QAT device. + Write to the file to change the configured services. + + The values are: + + * sym;asym: the device is configured for running crypto + services + * dc: the device is configured for running compression services It is possible to set the configuration only if the device is in the `down` state (see /sys/bus/pci/devices//qat/state) -- cgit