sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget4/translations/zh_CN/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/zh_TW/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/it_IT/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ja_JP/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ko_KR/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/sp_SP/driver-api/crypto/iaa/iaa-cryptomodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhN/var/lib/git/docbuild/linux/Documentation/driver-api/crypto/iaa/iaa-crypto.rsthKubhsection)}(hhh](htitle)}(h)IAA Compression Accelerator Crypto Driverh]h)IAA Compression Accelerator Crypto Driver}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(h)Tom Zanussi h](h Tom Zanussi <}(hhhhhNhNubh reference)}(htom.zanussi@linux.intel.comh]htom.zanussi@linux.intel.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refuri"mailto:tom.zanussi@linux.intel.comuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe IAA crypto driver supports compression/decompression compatible with the DEFLATE compression standard described in RFC 1951, which is the compression/decompression algorithm exported by this module.h]hThe IAA crypto driver supports compression/decompression compatible with the DEFLATE compression standard described in RFC 1951, which is the compression/decompression algorithm exported by this module.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(h(The IAA hardware spec can be found here:h]h(The IAA hardware spec can be found here:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh block_quote)}(h1https://cdrdv2.intel.com/v1/dl/getContent/721858 h]h)}(h0https://cdrdv2.intel.com/v1/dl/getContent/721858h]h)}(hjh]h0https://cdrdv2.intel.com/v1/dl/getContent/721858}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j hhhKhhhhubh)}(hoThe iaa_crypto driver is designed to work as a layer underneath higher-level compression devices such as zswap.h]hoThe iaa_crypto driver is designed to work as a layer underneath higher-level compression devices such as zswap.}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hUsers can select IAA compress/decompress acceleration by specifying one of the supported IAA compression algorithms in whatever facility allows compression algorithms to be selected.h]hUsers can select IAA compress/decompress acceleration by specifying one of the supported IAA compression algorithms in whatever facility allows compression algorithms to be selected.}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hFor example, a zswap device can select the IAA 'fixed' mode represented by selecting the 'deflate-iaa' crypto compression algorithm::h]hFor example, a zswap device can select the IAA ‘fixed’ mode represented by selecting the ‘deflate-iaa’ crypto compression algorithm:}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(h<# echo deflate-iaa > /sys/module/zswap/parameters/compressorh]h<# echo deflate-iaa > /sys/module/zswap/parameters/compressor}hj[sbah}(h]h ]h"]h$]h&]hhuh1jYhhhKhhhhubh)}(haThis will tell zswap to use the IAA 'fixed' compression mode for all compresses and decompresses.h]heThis will tell zswap to use the IAA ‘fixed’ compression mode for all compresses and decompresses.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hGCurrently, there is only one compression modes available, 'fixed' mode.h]hKCurrently, there is only one compression modes available, ‘fixed’ mode.}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hhhhubh)}(hXThe 'fixed' compression mode implements the compression scheme specified by RFC 1951 and is given the crypto algorithm name 'deflate-iaa'. (Because the IAA hardware has a 4k history-window limitation, only buffers <= 4k, or that have been compressed using a <= 4k history window, are technically compliant with the deflate spec, which allows for a window of up to 32k. Because of this limitation, the IAA fixed mode deflate algorithm is given its own algorithm name rather than simply 'deflate').h]hXThe ‘fixed’ compression mode implements the compression scheme specified by RFC 1951 and is given the crypto algorithm name ‘deflate-iaa’. (Because the IAA hardware has a 4k history-window limitation, only buffers <= 4k, or that have been compressed using a <= 4k history window, are technically compliant with the deflate spec, which allows for a window of up to 32k. Because of this limitation, the IAA fixed mode deflate algorithm is given its own algorithm name rather than simply ‘deflate’).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hhhhubh)}(hhh](h)}(hConfig options and other setuph]hConfig options and other setup}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK/ubh)}(hLThe IAA crypto driver is available via menuconfig using the following path::h]hKThe IAA crypto driver is available via menuconfig using the following path:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hjhhubjZ)}(h`Cryptographic API -> Hardware crypto devices -> Support for Intel(R) IAA Compression Acceleratorh]h`Cryptographic API -> Hardware crypto devices -> Support for Intel(R) IAA Compression Accelerator}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhK4hjhhubh)}(hIIn the configuration file the option called CONFIG_CRYPTO_DEV_IAA_CRYPTO.h]hIIn the configuration file the option called CONFIG_CRYPTO_DEV_IAA_CRYPTO.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjhhubh)}(hmThe IAA crypto driver also supports statistics, which are available via menuconfig using the following path::h]hlThe IAA crypto driver also supports statistics, which are available via menuconfig using the following path:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hjhhubjZ)}(hCryptographic API -> Hardware crypto devices -> Support for Intel(R) IAA Compression -> Enable Intel(R) IAA Compression Accelerator Statisticsh]hCryptographic API -> Hardware crypto devices -> Support for Intel(R) IAA Compression -> Enable Intel(R) IAA Compression Accelerator Statistics}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhK;hjhhubh)}(hOIn the configuration file the option called CONFIG_CRYPTO_DEV_IAA_CRYPTO_STATS.h]hOIn the configuration file the option called CONFIG_CRYPTO_DEV_IAA_CRYPTO_STATS.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hjhhubh)}(h5The following config options should also be enabled::h]h4The following config options should also be enabled:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hjhhubjZ)}(hCONFIG_IRQ_REMAP=y CONFIG_INTEL_IOMMU=y CONFIG_INTEL_IOMMU_SVM=y CONFIG_PCI_ATS=y CONFIG_PCI_PRI=y CONFIG_PCI_PASID=y CONFIG_INTEL_IDXD=m CONFIG_INTEL_IDXD_SVM=yh]hCONFIG_IRQ_REMAP=y CONFIG_INTEL_IOMMU=y CONFIG_INTEL_IOMMU_SVM=y CONFIG_PCI_ATS=y CONFIG_PCI_PRI=y CONFIG_PCI_PASID=y CONFIG_INTEL_IDXD=m CONFIG_INTEL_IDXD_SVM=y}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKAhjhhubh)}(hIAA is one of the first Intel accelerator IPs that can work in conjunction with the Intel IOMMU. There are multiple modes that exist for testing. Based on IOMMU configuration, there are 3 modes::h]hIAA is one of the first Intel accelerator IPs that can work in conjunction with the Intel IOMMU. There are multiple modes that exist for testing. Based on IOMMU configuration, there are 3 modes:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKJhjhhubjZ)}(h- Scalable - Legacy - No IOMMUh]h- Scalable - Legacy - No IOMMU}hj"sbah}(h]h ]h"]h$]h&]hhuh1jYhhhKNhjhhubh)}(hhh](h)}(h Scalable modeh]h Scalable mode}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj0hhhhhKTubh)}(hqScalable mode supports Shared Virtual Memory (SVM or SVA). It is entered when using the kernel boot commandline::h]hpScalable mode supports Shared Virtual Memory (SVM or SVA). It is entered when using the kernel boot commandline:}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhj0hhubjZ)}(hintel_iommu=on,sm_onh]hintel_iommu=on,sm_on}hjOsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKYhj0hhubh)}(hwith VT-d turned on in BIOS.h]hwith VT-d turned on in BIOS.}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hj0hhubh)}(hOWith scalable mode, both shared and dedicated workqueues are available for use.h]hOWith scalable mode, both shared and dedicated workqueues are available for use.}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hj0hhubh)}(hBFor scalable mode, the following BIOS settings should be enabled::h]hAFor scalable mode, the following BIOS settings should be enabled:}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hj0hhubjZ)}(hSocket Configuration > IIO Configuration > Intel VT for Directed I/O (VT-d) > Intel VT for Directed I/O Socket Configuration > IIO Configuration > PCIe ENQCMD > ENQCMDSh]hSocket Configuration > IIO Configuration > Intel VT for Directed I/O (VT-d) > Intel VT for Directed I/O Socket Configuration > IIO Configuration > PCIe ENQCMD > ENQCMDS}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKbhj0hhubeh}(h] scalable-modeah ]h"] scalable modeah$]h&]uh1hhjhhhhhKTubh)}(hhh](h)}(h Legacy modeh]h Legacy mode}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKhubh)}(h?Legacy mode is entered when using the kernel boot commandline::h]h>Legacy mode is entered when using the kernel boot commandline:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKjhjhhubjZ)}(hintel_iommu=offh]hintel_iommu=off}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKlhjhhubh)}(h!or VT-d is not turned on in BIOS.h]h!or VT-d is not turned on in BIOS.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjhhubh)}(hIf you have booted into Linux and not sure if VT-d is on, do a "dmesg | grep -i dmar". If you don't see a number of DMAR devices enumerated, most likely VT-d is not on.h]hIf you have booted into Linux and not sure if VT-d is on, do a “dmesg | grep -i dmar”. If you don’t see a number of DMAR devices enumerated, most likely VT-d is not on.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjhhubh)}(hBWith legacy mode, only dedicated workqueues are available for use.h]hBWith legacy mode, only dedicated workqueues are available for use.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthjhhubeh}(h] legacy-modeah ]h"] legacy modeah$]h&]uh1hhjhhhhhKhubh)}(hhh](h)}(h No IOMMU modeh]h No IOMMU mode}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKxubh)}(hANo IOMMU mode is entered when using the kernel boot commandline::h]h@No IOMMU mode is entered when using the kernel boot commandline:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjhhubjZ)}(h iommu=off.h]h iommu=off.}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhK|hjhhubh)}(hDWith no IOMMU mode, only dedicated workqueues are available for use.h]hDWith no IOMMU mode, only dedicated workqueues are available for use.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK~hjhhubeh}(h] no-iommu-modeah ]h"] no iommu modeah$]h&]uh1hhjhhhhhKxubeh}(h]config-options-and-other-setupah ]h"]config options and other setupah$]h&]uh1hhhhhhhhK/ubh)}(hhh](h)}(hUsageh]hUsage}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjGhhhhhKubh)}(hhh](h)}(h accel-configh]h accel-config}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjXhhhhhKubh)}(hXWhen loaded, the iaa_crypto driver automatically creates a default configuration and enables it, and assigns default driver attributes. If a different configuration or set of driver attributes is required, the user must first disable the IAA devices and workqueues, reset the configuration, and then re-register the deflate-iaa algorithm with the crypto subsystem by removing and reinserting the iaa_crypto module.h]hXWhen loaded, the iaa_crypto driver automatically creates a default configuration and enables it, and assigns default driver attributes. If a different configuration or set of driver attributes is required, the user must first disable the IAA devices and workqueues, reset the configuration, and then re-register the deflate-iaa algorithm with the crypto subsystem by removing and reinserting the iaa_crypto module.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hpThe :ref:`iaa_disable_script` in the 'Use Cases' section below can be used to disable the default configuration.h](hThe }(hjwhhhNhNubh)}(h:ref:`iaa_disable_script`h]hinline)}(hjh]hiaa_disable_script}(hjhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdoc driver-api/crypto/iaa/iaa-crypto refdomainjreftyperef refexplicitrefwarn reftargetiaa_disable_scriptuh1hhhhKhjwubhW in the ‘Use Cases’ section below can be used to disable the default configuration.}(hjwhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hMSee :ref:`iaa_default_config` below for details of the default configuration.h](hSee }(hjhhhNhNubh)}(h:ref:`iaa_default_config`h]j)}(hjh]hiaa_default_config}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjiaa_default_configuh1hhhhKhjubh0 below for details of the default configuration.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hMore likely than not, however, and because of the complexity and configurability of the accelerator devices, the user will want to configure the device and manually enable the desired devices and workqueues.h]hMore likely than not, however, and because of the complexity and configurability of the accelerator devices, the user will want to configure the device and manually enable the desired devices and workqueues.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hXThe userspace tool to help doing that is called accel-config. Using accel-config to configure device or loading a previously saved config is highly recommended. The device can be controlled via sysfs directly but comes with the warning that you should do this ONLY if you know exactly what you are doing. The following sections will not cover the sysfs interface but assumes you will be using accel-config.h]hXThe userspace tool to help doing that is called accel-config. Using accel-config to configure device or loading a previously saved config is highly recommended. The device can be controlled via sysfs directly but comes with the warning that you should do this ONLY if you know exactly what you are doing. The following sections will not cover the sysfs interface but assumes you will be using accel-config.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hyThe :ref:`iaa_sysfs_config` section in the appendix below can be consulted for the sysfs interface details if interested.h](hThe }(hjhhhNhNubh)}(h:ref:`iaa_sysfs_config`h]j)}(hjh]hiaa_sysfs_config}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjiaa_sysfs_configuh1hhhhKhjubh^ section in the appendix below can be consulted for the sysfs interface details if interested.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(hPThe accel-config tool along with instructions for building it can be found here:h]hPThe accel-config tool along with instructions for building it can be found here:}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubj )}(h-https://github.com/intel/idxd-config/#readme h]h)}(h,https://github.com/intel/idxd-config/#readmeh]h)}(hjBh]h,https://github.com/intel/idxd-config/#readme}(hjDhhhNhNubah}(h]h ]h"]h$]h&]refurijBuh1hhj@ubah}(h]h ]h"]h$]h&]uh1hhhhKhj<ubah}(h]h ]h"]h$]h&]uh1j hhhKhjXhhubeh}(h] accel-configah ]h"] accel-configah$]h&]uh1hhjGhhhhhKubh)}(hhh](h)}(h Typical usageh]h Typical usage}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhjfhhhhhKubh)}(hIn order for the iaa_crypto module to actually do any compression/decompression work on behalf of a facility, one or more IAA workqueues need to be bound to the iaa_crypto driver.h]hIn order for the iaa_crypto module to actually do any compression/decompression work on behalf of a facility, one or more IAA workqueues need to be bound to the iaa_crypto driver.}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubh)}(hFor instance, here's an example of configuring an IAA workqueue and binding it to the iaa_crypto driver (note that device names are specified as 'iax' rather than 'iaa' - this is because upstream still has the old 'iax' device naming in place) ::h]hXFor instance, here’s an example of configuring an IAA workqueue and binding it to the iaa_crypto driver (note that device names are specified as ‘iax’ rather than ‘iaa’ - this is because upstream still has the old ‘iax’ device naming in place)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubjZ)}(hXR# configure wq1.0 accel-config config-wq --group-id=0 --mode=dedicated --type=kernel --priority=10 --name="iaa_crypto" --driver-name="crypto" iax1/wq1.0 accel-config config-engine iax1/engine1.0 --group-id=0 # enable IAA device iax1 accel-config enable-device iax1 # enable wq1.0 on IAX device iax1 accel-config enable-wq iax1/wq1.0h]hXR# configure wq1.0 accel-config config-wq --group-id=0 --mode=dedicated --type=kernel --priority=10 --name="iaa_crypto" --driver-name="crypto" iax1/wq1.0 accel-config config-engine iax1/engine1.0 --group-id=0 # enable IAA device iax1 accel-config enable-device iax1 # enable wq1.0 on IAX device iax1 accel-config enable-wq iax1/wq1.0}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKhjfhhubh)}(hXWhenever a new workqueue is bound to or unbound from the iaa_crypto driver, the available workqueues are 'rebalanced' such that work submitted from a particular CPU is given to the most appropriate workqueue available. Current best practice is to configure and bind at least one workqueue for each IAA device, but as long as there is at least one workqueue configured and bound to any IAA device in the system, the iaa_crypto driver will work, albeit most likely not as efficiently.h]hXWhenever a new workqueue is bound to or unbound from the iaa_crypto driver, the available workqueues are ‘rebalanced’ such that work submitted from a particular CPU is given to the most appropriate workqueue available. Current best practice is to configure and bind at least one workqueue for each IAA device, but as long as there is at least one workqueue configured and bound to any IAA device in the system, the iaa_crypto driver will work, albeit most likely not as efficiently.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubh)}(hThe IAA crypto algorigthms is operational and compression and decompression operations are fully enabled following the successful binding of the first IAA workqueue to the iaa_crypto driver.h]hThe IAA crypto algorigthms is operational and compression and decompression operations are fully enabled following the successful binding of the first IAA workqueue to the iaa_crypto driver.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubh)}(hSimilarly, the IAA crypto algorithm is not operational and compression and decompression operations are disabled following the unbinding of the last IAA worqueue to the iaa_crypto driver.h]hSimilarly, the IAA crypto algorithm is not operational and compression and decompression operations are disabled following the unbinding of the last IAA worqueue to the iaa_crypto driver.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubh)}(hAs a result, the IAA crypto algorithms and thus the IAA hardware are only available when one or more workques are bound to the iaa_crypto driver.h]hAs a result, the IAA crypto algorithms and thus the IAA hardware are only available when one or more workques are bound to the iaa_crypto driver.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubh)}(h{When there are no IAA workqueues bound to the driver, the IAA crypto algorithms can be unregistered by removing the module.h]h{When there are no IAA workqueues bound to the driver, the IAA crypto algorithms can be unregistered by removing the module.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjfhhubeh}(h] typical-usageah ]h"] typical usageah$]h&]uh1hhjGhhhhhKubh)}(hhh](h)}(hDriver attributesh]hDriver attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hX&There are a couple user-configurable driver attributes that can be used to configure various modes of operation. They're listed below, along with their default values. To set any of these attributes, echo the appropriate values to the attribute file located under /sys/bus/dsa/drivers/crypto/h]hX(There are a couple user-configurable driver attributes that can be used to configure various modes of operation. They’re listed below, along with their default values. To set any of these attributes, echo the appropriate values to the attribute file located under /sys/bus/dsa/drivers/crypto/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe attribute settings at the time the IAA algorithms are registered are captured in each algorithm's crypto_ctx and used for all compresses and decompresses when using that algorithm.h]hThe attribute settings at the time the IAA algorithms are registered are captured in each algorithm’s crypto_ctx and used for all compresses and decompresses when using that algorithm.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe available attributes are:h]hThe available attributes are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj )}(hX - verify_compress Toggle compression verification. If set, each compress will be internally decompressed and the contents verified, returning error codes if unsuccessful. This can be toggled with 0/1:: echo 0 > /sys/bus/dsa/drivers/crypto/verify_compress The default setting is '1' - verify all compresses. - sync_mode Select mode to be used to wait for completion of each compresses and decompress operation. The crypto async interface support implemented by iaa_crypto provides an implementation that satisfies the interface but does so in a synchronous manner - it fills and submits the IDXD descriptor and then loops around waiting for it to complete before returning. This isn't a problem at the moment, since all existing callers (e.g. zswap) wrap any asynchronous callees in a synchronous wrapper anyway. The iaa_crypto driver does however provide true asynchronous support for callers that can make use of it. In this mode, it fills and submits the IDXD descriptor, then returns immediately with -EINPROGRESS. The caller can then either poll for completion itself, which requires specific code in the caller which currently nothing in the upstream kernel implements, or go to sleep and wait for an interrupt signaling completion. This latter mode is supported by current users in the kernel such as zswap via synchronous wrappers. Although it is supported this mode is significantly slower than the synchronous mode that does the polling in the iaa_crypto driver previously mentioned. This mode can be enabled by writing 'async_irq' to the sync_mode iaa_crypto driver attribute:: echo async_irq > /sys/bus/dsa/drivers/crypto/sync_mode Async mode without interrupts (caller must poll) can be enabled by writing 'async' to it (please see Caveat):: echo async > /sys/bus/dsa/drivers/crypto/sync_mode The mode that does the polling in the iaa_crypto driver can be enabled by writing 'sync' to it:: echo sync > /sys/bus/dsa/drivers/crypto/sync_mode The default mode is 'sync'. Caveat: since the only mechanism that iaa_crypto currently implements for async polling without interrupts is via the 'sync' mode as described earlier, writing 'async' to '/sys/bus/dsa/drivers/crypto/sync_mode' will internally enable the 'sync' mode. This is to ensure correct iaa_crypto behavior until true async polling without interrupts is enabled in iaa_crypto. h]h bullet_list)}(hhh](h list_item)}(hX8verify_compress Toggle compression verification. If set, each compress will be internally decompressed and the contents verified, returning error codes if unsuccessful. This can be toggled with 0/1:: echo 0 > /sys/bus/dsa/drivers/crypto/verify_compress The default setting is '1' - verify all compresses. h](h)}(hverify_compressh]hverify_compress}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5ubh)}(hToggle compression verification. If set, each compress will be internally decompressed and the contents verified, returning error codes if unsuccessful. This can be toggled with 0/1::h]hToggle compression verification. If set, each compress will be internally decompressed and the contents verified, returning error codes if unsuccessful. This can be toggled with 0/1:}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5ubjZ)}(h4echo 0 > /sys/bus/dsa/drivers/crypto/verify_compressh]h4echo 0 > /sys/bus/dsa/drivers/crypto/verify_compress}hjUsbah}(h]h ]h"]h$]h&]hhuh1jYhhhKhj5ubh)}(h3The default setting is '1' - verify all compresses.h]h7The default setting is ‘1’ - verify all compresses.}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj5ubeh}(h]h ]h"]h$]h&]uh1j3hj0ubj4)}(hX sync_mode Select mode to be used to wait for completion of each compresses and decompress operation. The crypto async interface support implemented by iaa_crypto provides an implementation that satisfies the interface but does so in a synchronous manner - it fills and submits the IDXD descriptor and then loops around waiting for it to complete before returning. This isn't a problem at the moment, since all existing callers (e.g. zswap) wrap any asynchronous callees in a synchronous wrapper anyway. The iaa_crypto driver does however provide true asynchronous support for callers that can make use of it. In this mode, it fills and submits the IDXD descriptor, then returns immediately with -EINPROGRESS. The caller can then either poll for completion itself, which requires specific code in the caller which currently nothing in the upstream kernel implements, or go to sleep and wait for an interrupt signaling completion. This latter mode is supported by current users in the kernel such as zswap via synchronous wrappers. Although it is supported this mode is significantly slower than the synchronous mode that does the polling in the iaa_crypto driver previously mentioned. This mode can be enabled by writing 'async_irq' to the sync_mode iaa_crypto driver attribute:: echo async_irq > /sys/bus/dsa/drivers/crypto/sync_mode Async mode without interrupts (caller must poll) can be enabled by writing 'async' to it (please see Caveat):: echo async > /sys/bus/dsa/drivers/crypto/sync_mode The mode that does the polling in the iaa_crypto driver can be enabled by writing 'sync' to it:: echo sync > /sys/bus/dsa/drivers/crypto/sync_mode The default mode is 'sync'. Caveat: since the only mechanism that iaa_crypto currently implements for async polling without interrupts is via the 'sync' mode as described earlier, writing 'async' to '/sys/bus/dsa/drivers/crypto/sync_mode' will internally enable the 'sync' mode. This is to ensure correct iaa_crypto behavior until true async polling without interrupts is enabled in iaa_crypto. h](h)}(h sync_modeh]h sync_mode}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubh)}(hZSelect mode to be used to wait for completion of each compresses and decompress operation.h]hZSelect mode to be used to wait for completion of each compresses and decompress operation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubh)}(hXThe crypto async interface support implemented by iaa_crypto provides an implementation that satisfies the interface but does so in a synchronous manner - it fills and submits the IDXD descriptor and then loops around waiting for it to complete before returning. This isn't a problem at the moment, since all existing callers (e.g. zswap) wrap any asynchronous callees in a synchronous wrapper anyway.h]hXThe crypto async interface support implemented by iaa_crypto provides an implementation that satisfies the interface but does so in a synchronous manner - it fills and submits the IDXD descriptor and then loops around waiting for it to complete before returning. This isn’t a problem at the moment, since all existing callers (e.g. zswap) wrap any asynchronous callees in a synchronous wrapper anyway.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubh)}(hXThe iaa_crypto driver does however provide true asynchronous support for callers that can make use of it. In this mode, it fills and submits the IDXD descriptor, then returns immediately with -EINPROGRESS. The caller can then either poll for completion itself, which requires specific code in the caller which currently nothing in the upstream kernel implements, or go to sleep and wait for an interrupt signaling completion. This latter mode is supported by current users in the kernel such as zswap via synchronous wrappers. Although it is supported this mode is significantly slower than the synchronous mode that does the polling in the iaa_crypto driver previously mentioned.h]hXThe iaa_crypto driver does however provide true asynchronous support for callers that can make use of it. In this mode, it fills and submits the IDXD descriptor, then returns immediately with -EINPROGRESS. The caller can then either poll for completion itself, which requires specific code in the caller which currently nothing in the upstream kernel implements, or go to sleep and wait for an interrupt signaling completion. This latter mode is supported by current users in the kernel such as zswap via synchronous wrappers. Although it is supported this mode is significantly slower than the synchronous mode that does the polling in the iaa_crypto driver previously mentioned.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjwubh)}(h^This mode can be enabled by writing 'async_irq' to the sync_mode iaa_crypto driver attribute::h]haThis mode can be enabled by writing ‘async_irq’ to the sync_mode iaa_crypto driver attribute:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjwubjZ)}(h6echo async_irq > /sys/bus/dsa/drivers/crypto/sync_modeh]h6echo async_irq > /sys/bus/dsa/drivers/crypto/sync_mode}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjwubh)}(hnAsync mode without interrupts (caller must poll) can be enabled by writing 'async' to it (please see Caveat)::h]hqAsync mode without interrupts (caller must poll) can be enabled by writing ‘async’ to it (please see Caveat):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjwubjZ)}(h2echo async > /sys/bus/dsa/drivers/crypto/sync_modeh]h2echo async > /sys/bus/dsa/drivers/crypto/sync_mode}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjwubh)}(h`The mode that does the polling in the iaa_crypto driver can be enabled by writing 'sync' to it::h]hcThe mode that does the polling in the iaa_crypto driver can be enabled by writing ‘sync’ to it:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjwubjZ)}(h1echo sync > /sys/bus/dsa/drivers/crypto/sync_modeh]h1echo sync > /sys/bus/dsa/drivers/crypto/sync_mode}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjwubh)}(hThe default mode is 'sync'.h]hThe default mode is ‘sync’.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjwubh)}(hXnCaveat: since the only mechanism that iaa_crypto currently implements for async polling without interrupts is via the 'sync' mode as described earlier, writing 'async' to '/sys/bus/dsa/drivers/crypto/sync_mode' will internally enable the 'sync' mode. This is to ensure correct iaa_crypto behavior until true async polling without interrupts is enabled in iaa_crypto.h]hX~Caveat: since the only mechanism that iaa_crypto currently implements for async polling without interrupts is via the ‘sync’ mode as described earlier, writing ‘async’ to ‘/sys/bus/dsa/drivers/crypto/sync_mode’ will internally enable the ‘sync’ mode. This is to ensure correct iaa_crypto behavior until true async polling without interrupts is enabled in iaa_crypto.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjwubeh}(h]h ]h"]h$]h&]uh1j3hj0ubeh}(h]h ]h"]h$]h&]bullet-uh1j.hhhKhj*ubah}(h]h ]h"]h$]h&]uh1j hhhKhjhhubhtarget)}(h.. _iaa_default_config:h]h}(h]h ]h"]h$]h&]refidiaa-default-configuh1j7hM%hjhhhhubeh}(h]driver-attributesah ]h"]driver attributesah$]h&]uh1hhjGhhhhhKubh)}(hhh](h)}(hIAA Default Configurationh]hIAA Default Configuration}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMhhhhhM(ubh)}(hWhen the iaa_crypto driver is loaded, each IAA device has a single work queue configured for it, with the following attributes::h]hWhen the iaa_crypto driver is loaded, each IAA device has a single work queue configured for it, with the following attributes:}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM*hjMhhubjZ)}(hmode "dedicated" threshold 0 size Total WQ Size from WQCAP priority 10 type IDXD_WQT_KERNEL group 0 name "iaa_crypto" driver_name "crypto"h]hmode "dedicated" threshold 0 size Total WQ Size from WQCAP priority 10 type IDXD_WQT_KERNEL group 0 name "iaa_crypto" driver_name "crypto"}hjlsbah}(h]h ]h"]h$]h&]hhuh1jYhhhM-hjMhhubh)}(h~The devices and workqueues are also enabled and therefore the driver is ready to be used without any additional configuration.h]h~The devices and workqueues are also enabled and therefore the driver is ready to be used without any additional configuration.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM6hjMhhubh)}(hGThe default driver attributes in effect when the driver is loaded are::h]hFThe default driver attributes in effect when the driver is loaded are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjMhhubjZ)}(h,sync_mode "sync" verify_compress 1h]h,sync_mode "sync" verify_compress 1}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhM;hjMhhubh)}(hXIn order to change either the device/work queue or driver attributes, the enabled devices and workqueues must first be disabled. In order to have the new configuration applied to the deflate-iaa crypto algorithm, it needs to be re-registered by removing and reinserting the iaa_crypto module. The :ref:`iaa_disable_script` in the 'Use Cases' section below can be used to disable the default configuration.h](hX+In order to change either the device/work queue or driver attributes, the enabled devices and workqueues must first be disabled. In order to have the new configuration applied to the deflate-iaa crypto algorithm, it needs to be re-registered by removing and reinserting the iaa_crypto module. The }(hjhhhNhNubh)}(h:ref:`iaa_disable_script`h]j)}(hjh]hiaa_disable_script}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjiaa_disable_scriptuh1hhhhM>hjubhW in the ‘Use Cases’ section below can be used to disable the default configuration.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM>hjMhhubeh}(h](iaa-default-configurationjDeh ]h"](iaa default configurationiaa_default_configeh$]h&]uh1hhjGhhhhhM(expect_referenced_by_name}jj9sexpect_referenced_by_id}jDj9subeh}(h]usageah ]h"]usageah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Statisticsh]h Statistics}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMFubh)}(hIf the optional debugfs statistics support is enabled, the IAA crypto driver will generate statistics which can be accessed in debugfs at::h]hIf the optional debugfs statistics support is enabled, the IAA crypto driver will generate statistics which can be accessed in debugfs at:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhjhhubjZ)}(hX# ls -al /sys/kernel/debug/iaa-crypto/ total 0 drwxr-xr-x 2 root root 0 Mar 3 07:55 . drwx------ 53 root root 0 Mar 3 07:55 .. -rw-r--r-- 1 root root 0 Mar 3 07:55 global_stats -rw-r--r-- 1 root root 0 Mar 3 07:55 stats_reset -rw-r--r-- 1 root root 0 Mar 3 07:55 wq_statsh]hX# ls -al /sys/kernel/debug/iaa-crypto/ total 0 drwxr-xr-x 2 root root 0 Mar 3 07:55 . drwx------ 53 root root 0 Mar 3 07:55 .. -rw-r--r-- 1 root root 0 Mar 3 07:55 global_stats -rw-r--r-- 1 root root 0 Mar 3 07:55 stats_reset -rw-r--r-- 1 root root 0 Mar 3 07:55 wq_stats}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMKhjhhubh)}(hlThe global_stats file shows a set of global statistics collected since the driver has been loaded or reset::h]hkThe global_stats file shows a set of global statistics collected since the driver has been loaded or reset:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjhhubjZ)}(hX*# cat global_stats global stats: total_comp_calls: 4300 total_decomp_calls: 4164 total_sw_decomp_calls: 0 total_comp_bytes_out: 5993989 total_decomp_bytes_in: 5993989 total_completion_einval_errors: 0 total_completion_timeout_errors: 0 total_completion_comp_buf_overflow_errors: 136h]hX*# cat global_stats global stats: total_comp_calls: 4300 total_decomp_calls: 4164 total_sw_decomp_calls: 0 total_comp_bytes_out: 5993989 total_decomp_bytes_in: 5993989 total_completion_einval_errors: 0 total_completion_timeout_errors: 0 total_completion_comp_buf_overflow_errors: 136}hj&sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMVhjhhubh)}(hiThe wq_stats file shows per-wq stats, a set for each iaa device and wq in addition to some global stats::h]hhThe wq_stats file shows per-wq stats, a set for each iaa device and wq in addition to some global stats:}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMahjhhubjZ)}(hXy# cat wq_stats iaa device: id: 1 n_wqs: 1 comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 3 n_wqs: 1 comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 5 n_wqs: 1 comp_calls: 1360 comp_bytes: 1999776 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 1360 comp_bytes: 1999776 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 7 n_wqs: 1 comp_calls: 2940 comp_bytes: 3994213 decomp_calls: 4164 decomp_bytes: 5993989 wqs: name: iaa_crypto comp_calls: 2940 comp_bytes: 3994213 decomp_calls: 4164 decomp_bytes: 5993989 ...h]hXy# cat wq_stats iaa device: id: 1 n_wqs: 1 comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 3 n_wqs: 1 comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 0 comp_bytes: 0 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 5 n_wqs: 1 comp_calls: 1360 comp_bytes: 1999776 decomp_calls: 0 decomp_bytes: 0 wqs: name: iaa_crypto comp_calls: 1360 comp_bytes: 1999776 decomp_calls: 0 decomp_bytes: 0 iaa device: id: 7 n_wqs: 1 comp_calls: 2940 comp_bytes: 3994213 decomp_calls: 4164 decomp_bytes: 5993989 wqs: name: iaa_crypto comp_calls: 2940 comp_bytes: 3994213 decomp_calls: 4164 decomp_bytes: 5993989 ...}hjBsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMdhjhhubh)}(hZWriting to 'stats_reset' resets all the stats, including the per-device and per-wq stats::h]h]Writing to ‘stats_reset’ resets all the stats, including the per-device and per-wq stats:}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX# echo 1 > stats_reset # cat wq_stats global stats: total_comp_calls: 0 total_decomp_calls: 0 total_comp_bytes_out: 0 total_decomp_bytes_in: 0 total_completion_einval_errors: 0 total_completion_timeout_errors: 0 total_completion_comp_buf_overflow_errors: 0 ...h]hX# echo 1 > stats_reset # cat wq_stats global stats: total_comp_calls: 0 total_decomp_calls: 0 total_comp_bytes_out: 0 total_decomp_bytes_in: 0 total_completion_einval_errors: 0 total_completion_timeout_errors: 0 total_completion_comp_buf_overflow_errors: 0 ...}hj^sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubeh}(h] statisticsah ]h"] statisticsah$]h&]uh1hhhhhhhhMFubh)}(hhh](h)}(h Use casesh]h Use cases}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjthhhhhMubh)}(hhh](h)}(hSimple zswap testh]hSimple zswap test}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hFor this example, the kernel should be configured according to the dedicated mode options described above, and zswap should be enabled as well::h]hFor this example, the kernel should be configured according to the dedicated mode options described above, and zswap should be enabled as well:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hCONFIG_ZSWAP=yh]hCONFIG_ZSWAP=y}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hXThis is a simple test that uses iaa_compress as the compressor for a swap (zswap) device. It sets up the zswap device and then uses the memory_memadvise program listed below to forcibly swap out and in a specified number of pages, demonstrating both compress and decompress.h]hXThis is a simple test that uses iaa_compress as the compressor for a swap (zswap) device. It sets up the zswap device and then uses the memory_memadvise program listed below to forcibly swap out and in a specified number of pages, demonstrating both compress and decompress.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThe zswap test expects the work queues for each IAA device on the system to be configured properly as a kernel workqueue with a workqueue driver_name of "crypto".h]hThe zswap test expects the work queues for each IAA device on the system to be configured properly as a kernel workqueue with a workqueue driver_name of “crypto”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h@The first step is to make sure the iaa_crypto module is loaded::h]h?The first step is to make sure the iaa_crypto module is loaded:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hmodprobe iaa_cryptoh]hmodprobe iaa_crypto}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hXIf the IAA devices and workqueues haven't previously been disabled and reconfigured, then the default configuration should be in place and no further IAA configuration is necessary. See :ref:`iaa_default_config` below for details of the default configuration.h](hIf the IAA devices and workqueues haven’t previously been disabled and reconfigured, then the default configuration should be in place and no further IAA configuration is necessary. See }(hjhhhNhNubh)}(h:ref:`iaa_default_config`h]j)}(hjh]hiaa_default_config}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjiaa_default_configuh1hhhhMhjubh0 below for details of the default configuration.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h[If the default configuration is in place, you should see the iaa devices and wq0s enabled::h]hZIf the default configuration is in place, you should see the iaa devices and wq0s enabled:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(ha# cat /sys/bus/dsa/devices/iax1/state enabled # cat /sys/bus/dsa/devices/iax1/wq1.0/state enabledh]ha# cat /sys/bus/dsa/devices/iax1/state enabled # cat /sys/bus/dsa/devices/iax1/wq1.0/state enabled}hj*sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hmTo demonstrate that the following steps work as expected, these commands can be used to enable debug output::h]hlTo demonstrate that the following steps work as expected, these commands can be used to enable debug output:}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(h# echo -n 'module iaa_crypto +p' > /sys/kernel/debug/dynamic_debug/control # echo -n 'module idxd +p' > /sys/kernel/debug/dynamic_debug/controlh]h# echo -n 'module iaa_crypto +p' > /sys/kernel/debug/dynamic_debug/control # echo -n 'module idxd +p' > /sys/kernel/debug/dynamic_debug/control}hjFsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(h,Use the following commands to enable zswap::h]h+Use the following commands to enable zswap:}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX# echo 0 > /sys/module/zswap/parameters/enabled # echo 50 > /sys/module/zswap/parameters/max_pool_percent # echo deflate-iaa > /sys/module/zswap/parameters/compressor # echo zsmalloc > /sys/module/zswap/parameters/zpool # echo 1 > /sys/module/zswap/parameters/enabled # echo 100 > /proc/sys/vm/swappiness # echo never > /sys/kernel/mm/transparent_hugepage/enabled # echo 1 > /proc/sys/vm/overcommit_memoryh]hX# echo 0 > /sys/module/zswap/parameters/enabled # echo 50 > /sys/module/zswap/parameters/max_pool_percent # echo deflate-iaa > /sys/module/zswap/parameters/compressor # echo zsmalloc > /sys/module/zswap/parameters/zpool # echo 1 > /sys/module/zswap/parameters/enabled # echo 100 > /proc/sys/vm/swappiness # echo never > /sys/kernel/mm/transparent_hugepage/enabled # echo 1 > /proc/sys/vm/overcommit_memory}hjbsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hNow you can now run the zswap workload you want to measure. For example, using the memory_memadvise code below, the following command will swap in and out 100 pages::h]hNow you can now run the zswap workload you want to measure. For example, using the memory_memadvise code below, the following command will swap in and out 100 pages:}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(h./memory_madvise 100 Allocating 100 pages to swap in/out Swapping out 100 pages Swapping in 100 pages Swapped out and in 100 pagesh]h./memory_madvise 100 Allocating 100 pages to swap in/out Swapping out 100 pages Swapping in 100 pages Swapped out and in 100 pages}hj~sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hAYou should see something like the following in the dmesg output::h]h@You should see something like the following in the dmesg output:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX[ 404.202972] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, src_addr 223925c000, nr_sgs 1, req->src 00000000ee7cb5e6, req->slen 4096, sg_dma_len(sg) 4096 [ 404.202973] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, dst_addr 21dadf8000, nr_sgs 1, req->dst 000000008d6acea8, req->dlen 4096, sg_dma_len(sg) 8192 [ 404.202975] idxd 0000:e7:02.0: iaa_compress: desc->src1_addr 223925c000, desc->src1_size 4096, desc->dst_addr 21dadf8000, desc->max_dst_size 4096, desc->src2_addr 2203543000, desc->src2_size 1568 [ 404.202981] idxd 0000:e7:02.0: iaa_compress_verify: (verify) desc->src1_addr 21dadf8000, desc->src1_size 228, desc->dst_addr 223925c000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 ...h]hX[ 404.202972] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, src_addr 223925c000, nr_sgs 1, req->src 00000000ee7cb5e6, req->slen 4096, sg_dma_len(sg) 4096 [ 404.202973] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, dst_addr 21dadf8000, nr_sgs 1, req->dst 000000008d6acea8, req->dlen 4096, sg_dma_len(sg) 8192 [ 404.202975] idxd 0000:e7:02.0: iaa_compress: desc->src1_addr 223925c000, desc->src1_size 4096, desc->dst_addr 21dadf8000, desc->max_dst_size 4096, desc->src2_addr 2203543000, desc->src2_size 1568 [ 404.202981] idxd 0000:e7:02.0: iaa_compress_verify: (verify) desc->src1_addr 21dadf8000, desc->src1_size 228, desc->dst_addr 223925c000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 ...}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hNow that basic functionality has been demonstrated, the defaults can be erased and replaced with a different configuration. To do that, first disable zswap::h]hNow that basic functionality has been demonstrated, the defaults can be erased and replaced with a different configuration. To do that, first disable zswap:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX# echo lzo > /sys/module/zswap/parameters/compressor # swapoff -a # echo 0 > /sys/module/zswap/parameters/accept_threshold_percent # echo 0 > /sys/module/zswap/parameters/max_pool_percent # echo 0 > /sys/module/zswap/parameters/enabled # echo 0 > /sys/module/zswap/parameters/enabledh]hX# echo lzo > /sys/module/zswap/parameters/compressor # swapoff -a # echo 0 > /sys/module/zswap/parameters/accept_threshold_percent # echo 0 > /sys/module/zswap/parameters/max_pool_percent # echo 0 > /sys/module/zswap/parameters/enabled # echo 0 > /sys/module/zswap/parameters/enabled}hjsbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hmThen run the :ref:`iaa_disable_script` in the 'Use Cases' section below to disable the default configuration.h](h Then run the }(hjhhhNhNubh)}(h:ref:`iaa_disable_script`h]j)}(hjh]hiaa_disable_script}(hjhhhNhNubah}(h]h ](jstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftyperef refexplicitrefwarnjiaa_disable_scriptuh1hhhhMhjubhK in the ‘Use Cases’ section below to disable the default configuration.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hFinally turn swap back on::h]hFinally turn swap back on:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(h # swapon -ah]h # swapon -a}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hFollowing all that the IAA device(s) can now be re-configured and enabled as desired for further testing. Below is one example.h]hFollowing all that the IAA device(s) can now be re-configured and enabled as desired for further testing. Below is one example.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(hThe zswap test expects the work queues for each IAA device on the system to be configured properly as a kernel workqueue with a workqueue driver_name of "crypto".h]hThe zswap test expects the work queues for each IAA device on the system to be configured properly as a kernel workqueue with a workqueue driver_name of “crypto”.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(h*The below script automatically does that::h]h)The below script automatically does that:}(hj. hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX#!/bin/bash echo "IAA devices:" lspci -d:0cfe echo "# IAA devices:" lspci -d:0cfe | wc -l # # count iaa instances # iaa_dev_id="0cfe" num_iaa=$(lspci -d:${iaa_dev_id} | wc -l) echo "Found ${num_iaa} IAA instances" # # disable iaa wqs and devices # echo "Disable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo disable wq iax${i}/wq${i}.0 accel-config disable-wq iax${i}/wq${i}.0 echo disable iaa iax${i} accel-config disable-device iax${i} done echo "End Disable IAA" echo "Reload iaa_crypto module" rmmod iaa_crypto modprobe iaa_crypto echo "End Reload iaa_crypto module" # # configure iaa wqs and devices # echo "Configure IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do accel-config config-wq --group-id=0 --mode=dedicated --wq-size=128 --priority=10 --type=kernel --name="iaa_crypto" --driver-name="crypto" iax${i}/wq${i}.0 accel-config config-engine iax${i}/engine${i}.0 --group-id=0 done echo "End Configure IAA" # # enable iaa wqs and devices # echo "Enable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo enable iaa iax${i} accel-config enable-device iax${i} echo enable wq iax${i}/wq${i}.0 accel-config enable-wq iax${i}/wq${i}.0 done echo "End Enable IAA"h]hX#!/bin/bash echo "IAA devices:" lspci -d:0cfe echo "# IAA devices:" lspci -d:0cfe | wc -l # # count iaa instances # iaa_dev_id="0cfe" num_iaa=$(lspci -d:${iaa_dev_id} | wc -l) echo "Found ${num_iaa} IAA instances" # # disable iaa wqs and devices # echo "Disable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo disable wq iax${i}/wq${i}.0 accel-config disable-wq iax${i}/wq${i}.0 echo disable iaa iax${i} accel-config disable-device iax${i} done echo "End Disable IAA" echo "Reload iaa_crypto module" rmmod iaa_crypto modprobe iaa_crypto echo "End Reload iaa_crypto module" # # configure iaa wqs and devices # echo "Configure IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do accel-config config-wq --group-id=0 --mode=dedicated --wq-size=128 --priority=10 --type=kernel --name="iaa_crypto" --driver-name="crypto" iax${i}/wq${i}.0 accel-config config-engine iax${i}/engine${i}.0 --group-id=0 done echo "End Configure IAA" # # enable iaa wqs and devices # echo "Enable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo enable iaa iax${i} accel-config enable-device iax${i} echo enable wq iax${i}/wq${i}.0 accel-config enable-wq iax${i}/wq${i}.0 done echo "End Enable IAA"}hj< sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hWhen the workqueues are bound to the iaa_crypto driver, you should see something similar to the following in dmesg output if you've enabled debug output (echo -n 'module iaa_crypto +p' > /sys/kernel/debug/dynamic_debug/control)::h]hWhen the workqueues are bound to the iaa_crypto driver, you should see something similar to the following in dmesg output if you’ve enabled debug output (echo -n ‘module iaa_crypto +p’ > /sys/kernel/debug/dynamic_debug/control):}(hjJ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMOhjhhubjZ)}(hXr[ 60.752344] idxd 0000:f6:02.0: add_iaa_wq: added wq 000000004068d14d to iaa 00000000c9585ba2, n_wq 1 [ 60.752346] iaa_crypto: rebalance_wq_table: nr_nodes=2, nr_cpus 160, nr_iaa 8, cpus_per_iaa 20 [ 60.752347] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752349] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752350] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752352] iaa_crypto: rebalance_wq_table: assigned wq for cpu=0, node=0 = wq 00000000c8bb4452 [ 60.752354] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752355] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752356] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752358] iaa_crypto: rebalance_wq_table: assigned wq for cpu=1, node=0 = wq 00000000c8bb4452 [ 60.752359] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752360] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752361] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752362] iaa_crypto: rebalance_wq_table: assigned wq for cpu=2, node=0 = wq 00000000c8bb4452 [ 60.752364] iaa_crypto: rebalance_wq_table: iaa=0 . . .h]hXr[ 60.752344] idxd 0000:f6:02.0: add_iaa_wq: added wq 000000004068d14d to iaa 00000000c9585ba2, n_wq 1 [ 60.752346] iaa_crypto: rebalance_wq_table: nr_nodes=2, nr_cpus 160, nr_iaa 8, cpus_per_iaa 20 [ 60.752347] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752349] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752350] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752352] iaa_crypto: rebalance_wq_table: assigned wq for cpu=0, node=0 = wq 00000000c8bb4452 [ 60.752354] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752355] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752356] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752358] iaa_crypto: rebalance_wq_table: assigned wq for cpu=1, node=0 = wq 00000000c8bb4452 [ 60.752359] iaa_crypto: rebalance_wq_table: iaa=0 [ 60.752360] idxd 0000:6a:02.0: request_iaa_wq: getting wq from iaa_device 0000000042d7bc52 (0) [ 60.752361] idxd 0000:6a:02.0: request_iaa_wq: returning unused wq 00000000c8bb4452 (0) from iaa device 0000000042d7bc52 (0) [ 60.752362] iaa_crypto: rebalance_wq_table: assigned wq for cpu=2, node=0 = wq 00000000c8bb4452 [ 60.752364] iaa_crypto: rebalance_wq_table: iaa=0 . . .}hjX sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMThjhhubh)}(hOnce the workqueues and devices have been enabled, the IAA crypto algorithms are enabled and available. When the IAA crypto algorithms have been successfully enabled, you should see the following dmesg output::h]hOnce the workqueues and devices have been enabled, the IAA crypto algorithms are enabled and available. When the IAA crypto algorithms have been successfully enabled, you should see the following dmesg output:}(hjf hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghjhhubjZ)}(hD[ 64.893759] iaa_crypto: iaa_crypto_enable: iaa_crypto now ENABLEDh]hD[ 64.893759] iaa_crypto: iaa_crypto_enable: iaa_crypto now ENABLED}hjt sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMlhjhhubh)}(hdNow run the following zswap-specific setup commands to have zswap use the 'fixed' compression mode::h]hgNow run the following zswap-specific setup commands to have zswap use the ‘fixed’ compression mode:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhjhhubjZ)}(hXecho 0 > /sys/module/zswap/parameters/enabled echo 50 > /sys/module/zswap/parameters/max_pool_percent echo deflate-iaa > /sys/module/zswap/parameters/compressor echo zsmalloc > /sys/module/zswap/parameters/zpool echo 1 > /sys/module/zswap/parameters/enabled echo 100 > /proc/sys/vm/swappiness echo never > /sys/kernel/mm/transparent_hugepage/enabled echo 1 > /proc/sys/vm/overcommit_memoryh]hXecho 0 > /sys/module/zswap/parameters/enabled echo 50 > /sys/module/zswap/parameters/max_pool_percent echo deflate-iaa > /sys/module/zswap/parameters/compressor echo zsmalloc > /sys/module/zswap/parameters/zpool echo 1 > /sys/module/zswap/parameters/enabled echo 100 > /proc/sys/vm/swappiness echo never > /sys/kernel/mm/transparent_hugepage/enabled echo 1 > /proc/sys/vm/overcommit_memory}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMqhjhhubh)}(hFinally, you can now run the zswap workload you want to measure. For example, using the code below, the following command will swap in and out 100 pages::h]hFinally, you can now run the zswap workload you want to measure. For example, using the code below, the following command will swap in and out 100 pages:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhDehM{hjhhubjZ)}(h./memory_madvise 100 Allocating 100 pages to swap in/out Swapping out 100 pages Swapping in 100 pages Swapped out and in 100 pagesh]h./memory_madvise 100 Allocating 100 pages to swap in/out Swapping out 100 pages Swapping in 100 pages Swapped out and in 100 pages}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hYou should see something like the following in the dmesg output if you've enabled debug output (echo -n 'module iaa_crypto +p' > /sys/kernel/debug/dynamic_debug/control)::h]hYou should see something like the following in the dmesg output if you’ve enabled debug output (echo -n ‘module iaa_crypto +p’ > /sys/kernel/debug/dynamic_debug/control):}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hX[ 404.202972] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, src_addr 223925c000, nr_sgs 1, req->src 00000000ee7cb5e6, req->slen 4096, sg_dma_len(sg) 4096 [ 404.202973] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, dst_addr 21dadf8000, nr_sgs 1, req->dst 000000008d6acea8, req->dlen 4096, sg_dma_len(sg) 8192 [ 404.202975] idxd 0000:e7:02.0: iaa_compress: desc->src1_addr 223925c000, desc->src1_size 4096, desc->dst_addr 21dadf8000, desc->max_dst_size 4096, desc->src2_addr 2203543000, desc->src2_size 1568 [ 404.202981] idxd 0000:e7:02.0: iaa_compress_verify: (verify) desc->src1_addr 21dadf8000, desc->src1_size 228, desc->dst_addr 223925c000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 [ 409.203227] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, src_addr 21ddd8b100, nr_sgs 1, req->src 0000000084adab64, req->slen 228, sg_dma_len(sg) 228 [ 409.203235] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, dst_addr 21ee3dc000, nr_sgs 1, req->dst 000000004e2990d0, req->dlen 4096, sg_dma_len(sg) 4096 [ 409.203239] idxd 0000:e7:02.0: iaa_decompress: desc->src1_addr 21ddd8b100, desc->src1_size 228, desc->dst_addr 21ee3dc000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 [ 409.203254] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, src_addr 21ddd8b100, nr_sgs 1, req->src 0000000084adab64, req->slen 228, sg_dma_len(sg) 228 [ 409.203256] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, dst_addr 21f1551000, nr_sgs 1, req->dst 000000004e2990d0, req->dlen 4096, sg_dma_len(sg) 4096 [ 409.203257] idxd 0000:e7:02.0: iaa_decompress: desc->src1_addr 21ddd8b100, desc->src1_size 228, desc->dst_addr 21f1551000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0h]hX[ 404.202972] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, src_addr 223925c000, nr_sgs 1, req->src 00000000ee7cb5e6, req->slen 4096, sg_dma_len(sg) 4096 [ 404.202973] idxd 0000:e7:02.0: iaa_comp_acompress: dma_map_sg, dst_addr 21dadf8000, nr_sgs 1, req->dst 000000008d6acea8, req->dlen 4096, sg_dma_len(sg) 8192 [ 404.202975] idxd 0000:e7:02.0: iaa_compress: desc->src1_addr 223925c000, desc->src1_size 4096, desc->dst_addr 21dadf8000, desc->max_dst_size 4096, desc->src2_addr 2203543000, desc->src2_size 1568 [ 404.202981] idxd 0000:e7:02.0: iaa_compress_verify: (verify) desc->src1_addr 21dadf8000, desc->src1_size 228, desc->dst_addr 223925c000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 [ 409.203227] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, src_addr 21ddd8b100, nr_sgs 1, req->src 0000000084adab64, req->slen 228, sg_dma_len(sg) 228 [ 409.203235] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, dst_addr 21ee3dc000, nr_sgs 1, req->dst 000000004e2990d0, req->dlen 4096, sg_dma_len(sg) 4096 [ 409.203239] idxd 0000:e7:02.0: iaa_decompress: desc->src1_addr 21ddd8b100, desc->src1_size 228, desc->dst_addr 21ee3dc000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0 [ 409.203254] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, src_addr 21ddd8b100, nr_sgs 1, req->src 0000000084adab64, req->slen 228, sg_dma_len(sg) 228 [ 409.203256] idxd 0000:e7:02.0: iaa_comp_adecompress: dma_map_sg, dst_addr 21f1551000, nr_sgs 1, req->dst 000000004e2990d0, req->dlen 4096, sg_dma_len(sg) 4096 [ 409.203257] idxd 0000:e7:02.0: iaa_decompress: desc->src1_addr 21ddd8b100, desc->src1_size 228, desc->dst_addr 21f1551000, desc->max_dst_size 4096, desc->src2_addr 0, desc->src2_size 0}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(hIn order to unregister the IAA crypto algorithms, and register new ones using different parameters, any users of the current algorithm should be stopped and the IAA workqueues and devices disabled.h]hIn order to unregister the IAA crypto algorithms, and register new ones using different parameters, any users of the current algorithm should be stopped and the IAA workqueues and devices disabled.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hIn the case of zswap, remove the IAA crypto algorithm as the compressor and turn off swap (to remove all references to iaa_crypto)::h]hIn the case of zswap, remove the IAA crypto algorithm as the compressor and turn off swap (to remove all references to iaa_crypto):}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubjZ)}(hecho lzo > /sys/module/zswap/parameters/compressor swapoff -a echo 0 > /sys/module/zswap/parameters/accept_threshold_percent echo 0 > /sys/module/zswap/parameters/max_pool_percent echo 0 > /sys/module/zswap/parameters/enabledh]hecho lzo > /sys/module/zswap/parameters/compressor swapoff -a echo 0 > /sys/module/zswap/parameters/accept_threshold_percent echo 0 > /sys/module/zswap/parameters/max_pool_percent echo 0 > /sys/module/zswap/parameters/enabled}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhjhhubh)}(h_Once zswap is disabled and no longer using iaa_crypto, the IAA wqs and devices can be disabled.h]h_Once zswap is disabled and no longer using iaa_crypto, the IAA wqs and devices can be disabled.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj8)}(h.. _iaa_disable_script:h]h}(h]h ]h"]h$]h&]jCiaa-disable-scriptuh1j7hMhjhhhhubeh}(h]simple-zswap-testah ]h"]simple zswap testah$]h&]uh1hhjthhhhhMubh)}(hhh](h)}(hIAA disable scripth]hIAA disable script}(hj$ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj! hhhhhMubh)}(h*The below script automatically does that::h]h)The below script automatically does that:}(hj2 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubjZ)}(hX#!/bin/bash echo "IAA devices:" lspci -d:0cfe echo "# IAA devices:" lspci -d:0cfe | wc -l # # count iaa instances # iaa_dev_id="0cfe" num_iaa=$(lspci -d:${iaa_dev_id} | wc -l) echo "Found ${num_iaa} IAA instances" # # disable iaa wqs and devices # echo "Disable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo disable wq iax${i}/wq${i}.0 accel-config disable-wq iax${i}/wq${i}.0 echo disable iaa iax${i} accel-config disable-device iax${i} done echo "End Disable IAA"h]hX#!/bin/bash echo "IAA devices:" lspci -d:0cfe echo "# IAA devices:" lspci -d:0cfe | wc -l # # count iaa instances # iaa_dev_id="0cfe" num_iaa=$(lspci -d:${iaa_dev_id} | wc -l) echo "Found ${num_iaa} IAA instances" # # disable iaa wqs and devices # echo "Disable IAA" for ((i = 1; i < ${num_iaa} * 2; i += 2)); do echo disable wq iax${i}/wq${i}.0 accel-config disable-wq iax${i}/wq${i}.0 echo disable iaa iax${i} accel-config disable-device iax${i} done echo "End Disable IAA"}hj@ sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhj! hhubh)}(hvFinally, at this point the iaa_crypto module can be removed, which will unregister the current IAA crypto algorithms::h]huFinally, at this point the iaa_crypto module can be removed, which will unregister the current IAA crypto algorithms:}(hjN hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj! hhubjZ)}(hrmmod iaa_cryptoh]hrmmod iaa_crypto}hj\ sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhj! hhubh)}(h=memory_madvise.c (gcc -o memory_memadvise memory_madvise.c)::h]h #include #include #include #include #include #ifndef MADV_PAGEOUT #define MADV_PAGEOUT 21 /* force pages out immediately */ #endif #define PG_SZ 4096 int main(int argc, char **argv) { int i, nr_pages = 1; int64_t *dump_ptr; char *addr, *a; int loop = 1; if (argc > 1) nr_pages = atoi(argv[1]); printf("Allocating %d pages to swap in/out\n", nr_pages); /* allocate pages */ addr = mmap(NULL, nr_pages * PG_SZ, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); *addr = 1; /* initialize data in page to all '*' chars */ memset(addr, '*', nr_pages * PG_SZ); printf("Swapping out %d pages\n", nr_pages); /* Tell kernel to swap it out */ madvise(addr, nr_pages * PG_SZ, MADV_PAGEOUT); while (loop > 0) { /* Wait for swap out to finish */ sleep(5); a = addr; printf("Swapping in %d pages\n", nr_pages); /* Access the page ... this will swap it back in again */ for (i = 0; i < nr_pages; i++) { if (a[0] != '*') { printf("Bad data from decompress!!!!!\n"); dump_ptr = (int64_t *)a; for (int j = 0; j < 100; j++) { printf(" page %d data: %#llx\n", i, *dump_ptr); dump_ptr++; } } a += PG_SZ; } loop --; } printf("Swapped out and in %d pages\n", nr_pages);h]hX#include #include #include #include #include #include #ifndef MADV_PAGEOUT #define MADV_PAGEOUT 21 /* force pages out immediately */ #endif #define PG_SZ 4096 int main(int argc, char **argv) { int i, nr_pages = 1; int64_t *dump_ptr; char *addr, *a; int loop = 1; if (argc > 1) nr_pages = atoi(argv[1]); printf("Allocating %d pages to swap in/out\n", nr_pages); /* allocate pages */ addr = mmap(NULL, nr_pages * PG_SZ, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); *addr = 1; /* initialize data in page to all '*' chars */ memset(addr, '*', nr_pages * PG_SZ); printf("Swapping out %d pages\n", nr_pages); /* Tell kernel to swap it out */ madvise(addr, nr_pages * PG_SZ, MADV_PAGEOUT); while (loop > 0) { /* Wait for swap out to finish */ sleep(5); a = addr; printf("Swapping in %d pages\n", nr_pages); /* Access the page ... this will swap it back in again */ for (i = 0; i < nr_pages; i++) { if (a[0] != '*') { printf("Bad data from decompress!!!!!\n"); dump_ptr = (int64_t *)a; for (int j = 0; j < 100; j++) { printf(" page %d data: %#llx\n", i, *dump_ptr); dump_ptr++; } } a += PG_SZ; } loop --; } printf("Swapped out and in %d pages\n", nr_pages);}hjx sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMhj! hhubeh}(h](j id1eh ]h"](iaa disable scriptiaa_disable_scripteh$]h&]uh1hhjthhhhhMj}j j sj}j j subeh}(h] use-casesah ]h"] use casesah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hAppendixh]hAppendix}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubj8)}(h.. _iaa_sysfs_config:h]h}(h]h ]h"]h$]h&]jCiaa-sysfs-configuh1j7hMhj hhhhubh)}(hhh](h)}(hIAA sysfs config interfaceh]hIAA sysfs config interface}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hXJBelow is a description of the IAA sysfs interface, which as mentioned in the main document, should only be used if you know exactly what you are doing. Even then, there's no compelling reason to use it directly since accel-config can do everything the sysfs interface can and in fact accel-config is based on it under the covers.h]hXLBelow is a description of the IAA sysfs interface, which as mentioned in the main document, should only be used if you know exactly what you are doing. Even then, there’s no compelling reason to use it directly since accel-config can do everything the sysfs interface can and in fact accel-config is based on it under the covers.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hXgThe 'IAA config path' is /sys/bus/dsa/devices and contains subdirectories representing each IAA device, workqueue, engine, and group. Note that in the sysfs interface, the IAA devices are actually named using iax e.g. iax1, iax3, etc. (Note that IAA devices are the odd-numbered devices; the even-numbered devices are DSA devices and can be ignored for IAA).h]hXkThe ‘IAA config path’ is /sys/bus/dsa/devices and contains subdirectories representing each IAA device, workqueue, engine, and group. Note that in the sysfs interface, the IAA devices are actually named using iax e.g. iax1, iax3, etc. (Note that IAA devices are the odd-numbered devices; the even-numbered devices are DSA devices and can be ignored for IAA).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hj hhubh)}(huThe 'IAA device bind path' is /sys/bus/dsa/drivers/idxd/bind and is the file that is written to enable an IAA device.h]hyThe ‘IAA device bind path’ is /sys/bus/dsa/drivers/idxd/bind and is the file that is written to enable an IAA device.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM(hj hhubh)}(h}The 'IAA workqueue bind path' is /sys/bus/dsa/drivers/crypto/bind and is the file that is written to enable an IAA workqueue.h]hThe ‘IAA workqueue bind path’ is /sys/bus/dsa/drivers/crypto/bind and is the file that is written to enable an IAA workqueue.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM+hj hhubh)}(hSimilarly /sys/bus/dsa/drivers/idxd/unbind and /sys/bus/dsa/drivers/crypto/unbind are used to disable IAA devices and workqueues.h]hSimilarly /sys/bus/dsa/drivers/idxd/unbind and /sys/bus/dsa/drivers/crypto/unbind are used to disable IAA devices and workqueues.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM.hj hhubh)}(hRThe basic sequence of commands needed to set up the IAA devices and workqueues is:h]hRThe basic sequence of commands needed to set up the IAA devices and workqueues is:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM2hj hhubhdefinition_list)}(hhh]hdefinition_list_item)}(hXFor each device:: 1) Disable any workqueues enabled on the device. For example to disable workques 0 and 1 on IAA device 3:: # echo wq3.0 > /sys/bus/dsa/drivers/crypto/unbind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/unbind 2) Disable the device. For example to disable IAA device 3:: # echo iax3 > /sys/bus/dsa/drivers/idxd/unbind 3) configure the desired workqueues. For example, to configure workqueue 3 on IAA device 3:: # echo dedicated > /sys/bus/dsa/devices/iax3/wq3.3/mode # echo 128 > /sys/bus/dsa/devices/iax3/wq3.3/size # echo 0 > /sys/bus/dsa/devices/iax3/wq3.3/group_id # echo 10 > /sys/bus/dsa/devices/iax3/wq3.3/priority # echo "kernel" > /sys/bus/dsa/devices/iax3/wq3.3/type # echo "iaa_crypto" > /sys/bus/dsa/devices/iax3/wq3.3/name # echo "crypto" > /sys/bus/dsa/devices/iax3/wq3.3/driver_name 4) Enable the device. For example to enable IAA device 3:: # echo iax3 > /sys/bus/dsa/drivers/idxd/bind 5) Enable the desired workqueues on the device. For example to enable workques 0 and 1 on IAA device 3:: # echo wq3.0 > /sys/bus/dsa/drivers/crypto/bind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/bindh](hterm)}(hFor each device::h]hFor each device::}(hj' hhhNhNubah}(h]h ]h"]h$]h&]uh1j% hhhMRhj! ubh definition)}(hhh]henumerated_list)}(hhh](j4)}(hDisable any workqueues enabled on the device. For example to disable workques 0 and 1 on IAA device 3:: # echo wq3.0 > /sys/bus/dsa/drivers/crypto/unbind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/unbind h](h)}(hhDisable any workqueues enabled on the device. For example to disable workques 0 and 1 on IAA device 3::h]hgDisable any workqueues enabled on the device. For example to disable workques 0 and 1 on IAA device 3:}(hjC hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM6hj? ubjZ)}(hc# echo wq3.0 > /sys/bus/dsa/drivers/crypto/unbind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/unbindh]hc# echo wq3.0 > /sys/bus/dsa/drivers/crypto/unbind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/unbind}hjQ sbah}(h]h ]h"]h$]h&]hhuh1jYhhhM9hj? ubeh}(h]h ]h"]h$]h&]uh1j3hj< ubj4)}(hlDisable the device. For example to disable IAA device 3:: # echo iax3 > /sys/bus/dsa/drivers/idxd/unbind h](h)}(h9Disable the device. For example to disable IAA device 3::h]h8Disable the device. For example to disable IAA device 3:}(hji hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hje ubjZ)}(h.# echo iax3 > /sys/bus/dsa/drivers/idxd/unbindh]h.# echo iax3 > /sys/bus/dsa/drivers/idxd/unbind}hjw sbah}(h]h ]h"]h$]h&]hhuh1jYhhhM>hje ubeh}(h]h ]h"]h$]h&]uh1j3hj< ubj4)}(hXconfigure the desired workqueues. For example, to configure workqueue 3 on IAA device 3:: # echo dedicated > /sys/bus/dsa/devices/iax3/wq3.3/mode # echo 128 > /sys/bus/dsa/devices/iax3/wq3.3/size # echo 0 > /sys/bus/dsa/devices/iax3/wq3.3/group_id # echo 10 > /sys/bus/dsa/devices/iax3/wq3.3/priority # echo "kernel" > /sys/bus/dsa/devices/iax3/wq3.3/type # echo "iaa_crypto" > /sys/bus/dsa/devices/iax3/wq3.3/name # echo "crypto" > /sys/bus/dsa/devices/iax3/wq3.3/driver_name h](h)}(hZconfigure the desired workqueues. For example, to configure workqueue 3 on IAA device 3::h]hYconfigure the desired workqueues. For example, to configure workqueue 3 on IAA device 3:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM@hj ubjZ)}(hX# echo dedicated > /sys/bus/dsa/devices/iax3/wq3.3/mode # echo 128 > /sys/bus/dsa/devices/iax3/wq3.3/size # echo 0 > /sys/bus/dsa/devices/iax3/wq3.3/group_id # echo 10 > /sys/bus/dsa/devices/iax3/wq3.3/priority # echo "kernel" > /sys/bus/dsa/devices/iax3/wq3.3/type # echo "iaa_crypto" > /sys/bus/dsa/devices/iax3/wq3.3/name # echo "crypto" > /sys/bus/dsa/devices/iax3/wq3.3/driver_nameh]hX# echo dedicated > /sys/bus/dsa/devices/iax3/wq3.3/mode # echo 128 > /sys/bus/dsa/devices/iax3/wq3.3/size # echo 0 > /sys/bus/dsa/devices/iax3/wq3.3/group_id # echo 10 > /sys/bus/dsa/devices/iax3/wq3.3/priority # echo "kernel" > /sys/bus/dsa/devices/iax3/wq3.3/type # echo "iaa_crypto" > /sys/bus/dsa/devices/iax3/wq3.3/name # echo "crypto" > /sys/bus/dsa/devices/iax3/wq3.3/driver_name}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMChj ubeh}(h]h ]h"]h$]h&]uh1j3hj< ubj4)}(hhEnable the device. For example to enable IAA device 3:: # echo iax3 > /sys/bus/dsa/drivers/idxd/bind h](h)}(h7Enable the device. For example to enable IAA device 3::h]h6Enable the device. For example to enable IAA device 3:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMKhj ubjZ)}(h,# echo iax3 > /sys/bus/dsa/drivers/idxd/bindh]h,# echo iax3 > /sys/bus/dsa/drivers/idxd/bind}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMMhj ubeh}(h]h ]h"]h$]h&]uh1j3hj< ubj4)}(hEnable the desired workqueues on the device. For example to enable workques 0 and 1 on IAA device 3:: # echo wq3.0 > /sys/bus/dsa/drivers/crypto/bind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/bindh](h)}(hfEnable the desired workqueues on the device. For example to enable workques 0 and 1 on IAA device 3::h]heEnable the desired workqueues on the device. For example to enable workques 0 and 1 on IAA device 3:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMOhj ubjZ)}(h_# echo wq3.0 > /sys/bus/dsa/drivers/crypto/bind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/bindh]h_# echo wq3.0 > /sys/bus/dsa/drivers/crypto/bind # echo wq3.1 > /sys/bus/dsa/drivers/crypto/bind}hj sbah}(h]h ]h"]h$]h&]hhuh1jYhhhMRhj ubeh}(h]h ]h"]h$]h&]uh1j3hj< ubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix)uh1j: hj7 ubah}(h]h ]h"]h$]h&]uh1j5 hj! ubeh}(h]h ]h"]h$]h&]uh1j hhhMRhj ubah}(h]h ]h"]h$]h&]uh1j hj hhhNhNubeh}(h](iaa-sysfs-config-interfacej eh ]h"](iaa sysfs config interfaceiaa_sysfs_configeh$]h&]uh1hhj hhhhhMj}j j sj}j j subeh}(h]appendixah ]h"]appendixah$]h&]uh1hhhhhhhhMubeh}(h])iaa-compression-accelerator-crypto-driverah ]h"])iaa compression accelerator crypto driverah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjX error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}(jD]j9aj ]j aj ]j aunameids}(j2 j/ jDjAjjjjj<j9jjjcj`jjjJjGjjDjjjqjnj j j j j j j j j* j' j j j j u nametypes}(j2 jDjjj<jjcjjJjjjqj j j j j* j j uh}(j/ hjAjjj0jjj9jjjGj`jXjjfjGjjDjMjjMjnjj jtj jj j! j j! j' j j j j j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jf KsRparse_messages]hsystem_message)}(hhh]h)}(h`Blank line missing before literal block (after the "::")? Interpreted as a definition list item.h]hdBlank line missing before literal block (after the “::”)? Interpreted as a definition list item.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypeINFOlineMSsourcehuh1j hj7 ubatransform_messages](j )}(hhh]h)}(hhh]h8Hyperlink target "iaa-default-config" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypej sourcehlineM%uh1j ubj )}(hhh]h)}(hhh]h8Hyperlink target "iaa-disable-script" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypej sourcehlineMuh1j ubj )}(hhh]h)}(hhh]h6Hyperlink target "iaa-sysfs-config" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypej sourcehlineMuh1j ube transformerN include_log] decorationNhhub.