xref: /dpdk/doc/guides/cryptodevs/qat.rst (revision 2a7bb4fdf61e9edfb7adbaecb50e728b82da9e23)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
25630257fSFerruh Yigit    Copyright(c) 2015-2016 Intel Corporation.
31703e94aSDeclan Doherty
4ae20c073SDeepak Kumar JainIntel(R) QuickAssist (QAT) Crypto Poll Mode Driver
5ae20c073SDeepak Kumar Jain==================================================
61703e94aSDeclan Doherty
759ad25feSFiona TraheQAT documentation consists of three parts:
859ad25feSFiona Trahe
959ad25feSFiona Trahe* Details of the symmetric crypto service below.
1043d162bcSThomas Monjalon* Details of the `compression service <http://doc.dpdk.org/guides/compressdevs/qat_comp.html>`_
1159ad25feSFiona Trahe  in the compressdev drivers section.
1259ad25feSFiona Trahe* Details of building the common QAT infrastructure and the PMDs to support the
1359ad25feSFiona Trahe  above services. See :ref:`building_qat` below.
1459ad25feSFiona Trahe
1559ad25feSFiona Trahe
1659ad25feSFiona TraheSymmetric Crypto Service on QAT
1759ad25feSFiona Trahe-------------------------------
1859ad25feSFiona Trahe
1959ad25feSFiona TraheThe QAT crypto PMD provides poll mode crypto driver support for the following
20f546c1edSFiona Trahehardware accelerator devices:
21f546c1edSFiona Trahe
22f546c1edSFiona Trahe* ``Intel QuickAssist Technology DH895xCC``
23f546c1edSFiona Trahe* ``Intel QuickAssist Technology C62x``
24f546c1edSFiona Trahe* ``Intel QuickAssist Technology C3xxx``
25259310f3SFiona Trahe* ``Intel QuickAssist Technology D15xx``
261f5e4053SFiona Trahe* ``Intel QuickAssist Technology C4xxx``
271703e94aSDeclan Doherty
281703e94aSDeclan Doherty
291703e94aSDeclan DohertyFeatures
3059ad25feSFiona Trahe~~~~~~~~
311703e94aSDeclan Doherty
321703e94aSDeclan DohertyThe QAT PMD has support for:
331703e94aSDeclan Doherty
341703e94aSDeclan DohertyCipher algorithms:
351703e94aSDeclan Doherty
36e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CBC``
37e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CTR``
38fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CBC``
39fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CBC``
40fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CBC``
41fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CTR``
42fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CTR``
43fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CTR``
44fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
45db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_NULL``
46d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
476cd8b4d8SArek Kusztal* ``RTE_CRYPTO_CIPHER_DES_CBC``
48d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_AES_DOCSISBPI``
49d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_DES_DOCSISBPI``
50d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``
511703e94aSDeclan Doherty
521703e94aSDeclan DohertyHash algorithms:
531703e94aSDeclan Doherty
541703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
55ebdbe12fSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
561703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
57d905ee32SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
581703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
591703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
60a38dfe97SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SNOW3G_UIA2``
6161ec5181SArek Kusztal* ``RTE_CRYPTO_AUTH_MD5_HMAC``
62db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_NULL``
63d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_KASUMI_F9``
642fa64f84SArek Kusztal* ``RTE_CRYPTO_AUTH_AES_GMAC``
65d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_AUTH_ZUC_EIA3``
6691c1daa4STomasz Cel* ``RTE_CRYPTO_AUTH_AES_CMAC``
671703e94aSDeclan Doherty
68b79e4c00SPablo de LaraSupported AEAD algorithms:
69655c901bSAndrea Grandi
70b79e4c00SPablo de Lara* ``RTE_CRYPTO_AEAD_AES_GCM``
717bd6f76eSTomasz Cel* ``RTE_CRYPTO_AEAD_AES_CCM``
72b79e4c00SPablo de Lara
731703e94aSDeclan Doherty
741703e94aSDeclan DohertyLimitations
7559ad25feSFiona Trahe~~~~~~~~~~~
761703e94aSDeclan Doherty
771703e94aSDeclan Doherty* Only supports the session-oriented API implementation (session-less APIs are not supported).
782142e6dcSPablo de Lara* SNOW 3G (UEA2), KASUMI (F8) and ZUC (EEA3) supported only if cipher length and offset fields are byte-multiple.
799333cfbaSPablo de Lara* SNOW 3G (UIA2) and ZUC (EIA3) supported only if hash length and offset fields are byte-multiple.
808831895bSFiona Trahe* No BSD support as BSD QAT kernel driver not available.
81d9b7d5bbSArek Kusztal* ZUC EEA3/EIA3 is not supported by dh895xcc devices
82*2a7bb4fdSFiona Trahe* Maximum additional authenticated data (AAD) for GCM is 240 bytes long and must be passed to the device in a buffer rounded up to the nearest block-size multiple (x16) and padded with zeros.
830a081a5fSAnatoly Burakov* Queue pairs are not thread-safe (that is, within a single queue pair, RX and TX from different lcores is not supported).
841703e94aSDeclan Doherty
85bb44fb6fSFiona TraheExtra notes on KASUMI F9
8659ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
871703e94aSDeclan Doherty
88bb44fb6fSFiona TraheWhen using KASUMI F9 authentication algorithm, the input buffer must be
89aa38c849SFiona Traheconstructed according to the
90aa38c849SFiona Trahe`3GPP KASUMI specification <http://cryptome.org/3gpp/35201-900.pdf>`_
91aa38c849SFiona Trahe(section 4.4, page 13). The input buffer has to have COUNT (4 bytes),
92aa38c849SFiona TraheFRESH (4 bytes), MESSAGE and DIRECTION (1 bit) concatenated. After the DIRECTION
93aa38c849SFiona Trahebit, a single '1' bit is appended, followed by between 0 and 7 '0' bits, so that
94aa38c849SFiona Trahethe total length of the buffer is multiple of 8 bits. Note that the actual
95aa38c849SFiona Trahemessage can be any length, specified in bits.
96bb44fb6fSFiona Trahe
97bb44fb6fSFiona TraheOnce this buffer is passed this way, when creating the crypto operation,
98aa38c849SFiona Trahelength of data to authenticate "op.sym.auth.data.length" must be the length
99bb44fb6fSFiona Traheof all the items described above, including the padding at the end.
100aa38c849SFiona TraheAlso, offset of data to authenticate "op.sym.auth.data.offset"
101bb44fb6fSFiona Trahemust be such that points at the start of the COUNT bytes.
102bb44fb6fSFiona Trahe
103bb44fb6fSFiona Trahe
104bb44fb6fSFiona Trahe
10559ad25feSFiona Trahe.. _building_qat:
10659ad25feSFiona Trahe
10759ad25feSFiona TraheBuilding PMDs on QAT
10859ad25feSFiona Trahe--------------------
109bb44fb6fSFiona Trahe
11002545b6cSFiona TraheA QAT device can host multiple acceleration services:
11102545b6cSFiona Trahe
11202545b6cSFiona Trahe* symmetric cryptography
11302545b6cSFiona Trahe* data compression
11402545b6cSFiona Trahe
11502545b6cSFiona TraheThese services are provided to DPDK applications via PMDs which register to
11602545b6cSFiona Traheimplement the corresponding cryptodev and compressdev APIs. The PMDs use
11702545b6cSFiona Trahecommon QAT driver code which manages the QAT PCI device. They also depend on a
11802545b6cSFiona TraheQAT kernel driver being installed on the platform, see :ref:`qat_kernel` below.
1191703e94aSDeclan Doherty
120bb44fb6fSFiona Trahe
12102545b6cSFiona TraheConfiguring and Building the DPDK QAT PMDs
12202545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12302545b6cSFiona Trahe
12402545b6cSFiona Trahe
12502545b6cSFiona TraheFurther information on configuring, building and installing DPDK is described
12643d162bcSThomas Monjalon`here <http://doc.dpdk.org/guides/linux_gsg/build_dpdk.html>`_.
12702545b6cSFiona Trahe
12802545b6cSFiona Trahe
12902545b6cSFiona TraheQuick instructions for QAT cryptodev PMD are as follows:
130d6740135SEoin Breen
131d6740135SEoin Breen.. code-block:: console
132d6740135SEoin Breen
133f546c1edSFiona Trahe	cd to the top-level DPDK directory
13402545b6cSFiona Trahe	make defconfig
135bb44fb6fSFiona Trahe	sed -i 's,\(CONFIG_RTE_LIBRTE_PMD_QAT_SYM\)=n,\1=y,' build/.config
136d6740135SEoin Breen	make
137d6740135SEoin Breen
13802545b6cSFiona TraheQuick instructions for QAT compressdev PMD are as follows:
139bb44fb6fSFiona Trahe
14002545b6cSFiona Trahe.. code-block:: console
141bb44fb6fSFiona Trahe
14202545b6cSFiona Trahe	cd to the top-level DPDK directory
14302545b6cSFiona Trahe	make defconfig
14402545b6cSFiona Trahe	make
145bb44fb6fSFiona Trahe
146bb44fb6fSFiona Trahe
1477ce27b9eSFiona TraheBuild Configuration
1487ce27b9eSFiona Trahe~~~~~~~~~~~~~~~~~~~
1497ce27b9eSFiona Trahe
1507ce27b9eSFiona TraheThese are the build configuration options affecting QAT, and their default values:
1517ce27b9eSFiona Trahe
1527ce27b9eSFiona Trahe.. code-block:: console
1537ce27b9eSFiona Trahe
1547ce27b9eSFiona Trahe	CONFIG_RTE_LIBRTE_PMD_QAT=y
1557ce27b9eSFiona Trahe	CONFIG_RTE_LIBRTE_PMD_QAT_SYM=n
1567ce27b9eSFiona Trahe	CONFIG_RTE_PMD_QAT_MAX_PCI_DEVICES=48
1577ce27b9eSFiona Trahe	CONFIG_RTE_PMD_QAT_COMP_SGL_MAX_SEGMENTS=16
1584e8f2d6aSFiona Trahe	CONFIG_RTE_PMD_QAT_COMP_IM_BUFFER_SIZE=65536
1597ce27b9eSFiona Trahe
1607ce27b9eSFiona TraheCONFIG_RTE_LIBRTE_PMD_QAT must be enabled for any QAT PMD to be built.
1617ce27b9eSFiona Trahe
1627ce27b9eSFiona TraheThe QAT cryptodev PMD has an external dependency on libcrypto, so is not
1637ce27b9eSFiona Trahebuilt by default. CONFIG_RTE_LIBRTE_PMD_QAT_SYM should be enabled to build it.
1647ce27b9eSFiona Trahe
1657ce27b9eSFiona TraheThe QAT compressdev PMD has no external dependencies, so needs no configuration
1667ce27b9eSFiona Traheoptions and is built by default.
1677ce27b9eSFiona Trahe
1687ce27b9eSFiona TraheThe number of VFs per PF varies - see table below. If multiple QAT packages are
1697ce27b9eSFiona Traheinstalled on a platform then CONFIG_RTE_PMD_QAT_MAX_PCI_DEVICES should be
1707ce27b9eSFiona Traheadjusted to the number of VFs which the QAT common code will need to handle.
1714e8f2d6aSFiona TraheNote, there are separate config items for max cryptodevs CONFIG_RTE_CRYPTO_MAX_DEVS
1724e8f2d6aSFiona Traheand max compressdevs CONFIG_RTE_COMPRESS_MAX_DEVS, if necessary these should be
1734e8f2d6aSFiona Traheadjusted to handle the total of QAT and other devices which the process will use.
1747ce27b9eSFiona Trahe
1757ce27b9eSFiona TraheQAT allocates internal structures to handle SGLs. For the compression service
1767ce27b9eSFiona TraheCONFIG_RTE_PMD_QAT_COMP_SGL_MAX_SEGMENTS can be changed if more segments are needed.
1777ce27b9eSFiona TraheAn extra (max_inflight_ops x 16) bytes per queue_pair will be used for every increment.
1787ce27b9eSFiona Trahe
1794e8f2d6aSFiona TraheQAT compression PMD needs intermediate buffers to support Deflate compression
1804e8f2d6aSFiona Trahewith Dynamic Huffman encoding. CONFIG_RTE_PMD_QAT_COMP_IM_BUFFER_SIZE
1814e8f2d6aSFiona Trahespecifies the size of a single buffer, the PMD will allocate a multiple of these,
1824e8f2d6aSFiona Traheplus some extra space for associated meta-data. For GEN2 devices, 20 buffers plus
1834e8f2d6aSFiona Trahe1472 bytes are allocated.
1844e8f2d6aSFiona Trahe
1854e8f2d6aSFiona Trahe.. Note::
1864e8f2d6aSFiona Trahe
1874e8f2d6aSFiona Trahe	If the compressed output of a Deflate operation using Dynamic Huffman
1884e8f2d6aSFiona Trahe        Encoding is too big to fit in an intermediate buffer, then the
1894e8f2d6aSFiona Trahe        operation will return RTE_COMP_OP_STATUS_ERROR and an error will be
1904e8f2d6aSFiona Trahe        displayed. Options for the application in this case
1914e8f2d6aSFiona Trahe        are to split the input data into smaller chunks and resubmit
1924e8f2d6aSFiona Trahe        in multiple operations or to configure QAT with
1934e8f2d6aSFiona Trahe        larger intermediate buffers.
1944e8f2d6aSFiona Trahe
195bb44fb6fSFiona Trahe
196bb44fb6fSFiona TraheDevice and driver naming
19759ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
198bb44fb6fSFiona Trahe
199bb44fb6fSFiona Trahe* The qat cryptodev driver name is "crypto_qat".
200aa38c849SFiona Trahe  The "rte_cryptodev_devices_get()" returns the devices exposed by this driver.
201bb44fb6fSFiona Trahe
202bb44fb6fSFiona Trahe* Each qat crypto device has a unique name, in format
203aa38c849SFiona Trahe  "<pci bdf>_<service>", e.g. "0000:41:01.0_qat_sym".
204aa38c849SFiona Trahe  This name can be passed to "rte_cryptodev_get_dev_id()" to get the device_id.
205bb44fb6fSFiona Trahe
206bb44fb6fSFiona Trahe.. Note::
207bb44fb6fSFiona Trahe
208aa38c849SFiona Trahe	The qat crypto driver name is passed to the dpdk-test-crypto-perf tool in the "-devtype" parameter.
209bb44fb6fSFiona Trahe
210bb44fb6fSFiona Trahe	The qat crypto device name is in the format of the slave parameter passed to the crypto scheduler.
211bb44fb6fSFiona Trahe
212df8cca46SFiona Trahe* The qat compressdev driver name is "compress_qat".
213bb44fb6fSFiona Trahe  The rte_compressdev_devices_get() returns the devices exposed by this driver.
214bb44fb6fSFiona Trahe
215bb44fb6fSFiona Trahe* Each qat compression device has a unique name, in format
216bb44fb6fSFiona Trahe  <pci bdf>_<service>, e.g. "0000:41:01.0_qat_comp".
217bb44fb6fSFiona Trahe  This name can be passed to rte_compressdev_get_dev_id() to get the device_id.
218bb44fb6fSFiona Trahe
21902545b6cSFiona Trahe.. _qat_kernel:
22002545b6cSFiona Trahe
22102545b6cSFiona TraheDependency on the QAT kernel driver
22202545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22302545b6cSFiona Trahe
22402545b6cSFiona TraheTo use QAT an SRIOV-enabled QAT kernel driver is required. The VF
22502545b6cSFiona Trahedevices created and initialised by this driver will be used by the QAT PMDs.
22602545b6cSFiona Trahe
22702545b6cSFiona TraheInstructions for installation are below, but first an explanation of the
22802545b6cSFiona Traherelationships between the PF/VF devices and the PMDs visible to
22902545b6cSFiona TraheDPDK applications.
23002545b6cSFiona Trahe
23102545b6cSFiona TraheEach QuickAssist PF device exposes a number of VF devices. Each VF device can
23202545b6cSFiona Traheenable one cryptodev PMD and/or one compressdev PMD.
23302545b6cSFiona TraheThese QAT PMDs share the same underlying device and pci-mgmt code, but are
23402545b6cSFiona Traheenumerated independently on their respective APIs and appear as independent
23502545b6cSFiona Trahedevices to applications.
23602545b6cSFiona Trahe
23702545b6cSFiona Trahe.. Note::
23802545b6cSFiona Trahe
23902545b6cSFiona Trahe   Each VF can only be used by one DPDK process. It is not possible to share
24002545b6cSFiona Trahe   the same VF across multiple processes, even if these processes are using
24102545b6cSFiona Trahe   different acceleration services.
24202545b6cSFiona Trahe
24302545b6cSFiona Trahe   Conversely one DPDK process can use one or more QAT VFs and can expose both
24402545b6cSFiona Trahe   cryptodev and compressdev instances on each of those VFs.
24502545b6cSFiona Trahe
246bb44fb6fSFiona Trahe
247bb44fb6fSFiona TraheAvailable kernel drivers
24859ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
249bb44fb6fSFiona Trahe
250bb44fb6fSFiona TraheKernel drivers for each device are listed in the following table. Scroll right
251aa38c849SFiona Traheto check that the driver and device supports the service you require.
252bb44fb6fSFiona Trahe
2531703e94aSDeclan Doherty
254f546c1edSFiona Trahe.. _table_qat_pmds_drivers:
255f546c1edSFiona Trahe
256f5160653SArek Kusztal.. table:: QAT device generations, devices and drivers
257f546c1edSFiona Trahe
258bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
259bb44fb6fSFiona Trahe   | Gen | Device   | Driver/ver    | Kernel Module | Pci Driver | PF Did | #PFs | VF Did | VFs/PF | cryptodev | compressdev |
260bb44fb6fSFiona Trahe   +=====+==========+===============+===============+============+========+======+========+========+===========+=============+
261bb44fb6fSFiona Trahe   | 1   | DH895xCC | linux/4.4+    | qat_dh895xcc  | dh895xcc   | 435    | 1    | 443    | 32     | Yes       | No          |
262bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
263bb44fb6fSFiona Trahe   | "   | "        | 01.org/4.2.0+ | "             | "          | "      | "    | "      | "      | Yes       | No          |
264bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
265bb44fb6fSFiona Trahe   | 2   | C62x     | linux/4.5+    | qat_c62x      | c6xx       | 37c8   | 3    | 37c9   | 16     | Yes       | No          |
266bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
267bb44fb6fSFiona Trahe   | "   | "        | 01.org/4.2.0+ | "             | "          | "      | "    | "      | "      | Yes       | Yes         |
268bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
269bb44fb6fSFiona Trahe   | 2   | C3xxx    | linux/4.5+    | qat_c3xxx     | c3xxx      | 19e2   | 1    | 19e3   | 16     | Yes       | No          |
270bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
271bb44fb6fSFiona Trahe   | "   | "        | 01.org/4.2.0+ | "             | "          | "      | "    | "      | "      | Yes       | Yes         |
272bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
273bb44fb6fSFiona Trahe   | 2   | D15xx    | p             | qat_d15xx     | d15xx      | 6f54   | 1    | 6f55   | 16     | Yes       | No          |
274bb44fb6fSFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
2751f5e4053SFiona Trahe   | 3   | C4xxx    | p             | qat_c4xxx     | c4xxx      | 18a0   | 1    | 18a1   | 128    | Yes       | No          |
2761f5e4053SFiona Trahe   +-----+----------+---------------+---------------+------------+--------+------+--------+--------+-----------+-------------+
277f546c1edSFiona Trahe
278f546c1edSFiona Trahe
279f546c1edSFiona TraheThe ``Driver`` column indicates either the Linux kernel version in which
280f546c1edSFiona Trahesupport for this device was introduced or a driver available on Intel's 01.org
281f546c1edSFiona Trahewebsite. There are both linux and 01.org kernel drivers available for some
282259310f3SFiona Trahedevices. p = release pending.
283f546c1edSFiona Trahe
284f546c1edSFiona TraheIf you are running on a kernel which includes a driver for your device, see
285f546c1edSFiona Trahe`Installation using kernel.org driver`_ below. Otherwise see
286f546c1edSFiona Trahe`Installation using 01.org QAT driver`_.
287f546c1edSFiona Trahe
288f546c1edSFiona Trahe
289f546c1edSFiona TraheInstallation using kernel.org driver
29059ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291f546c1edSFiona Trahe
292f546c1edSFiona TraheThe examples below are based on the C62x device, if you have a different device
293f546c1edSFiona Traheuse the corresponding values in the above table.
294f546c1edSFiona Trahe
295f546c1edSFiona TraheIn BIOS ensure that SRIOV is enabled and either:
296f546c1edSFiona Trahe
297f546c1edSFiona Trahe* Disable VT-d or
298f546c1edSFiona Trahe* Enable VT-d and set ``"intel_iommu=on iommu=pt"`` in the grub file.
299f546c1edSFiona Trahe
300f546c1edSFiona TraheCheck that the QAT driver is loaded on your system, by executing::
301f546c1edSFiona Trahe
302f546c1edSFiona Trahe    lsmod | grep qa
303f546c1edSFiona Trahe
304f546c1edSFiona TraheYou should see the kernel module for your device listed, e.g.::
305f546c1edSFiona Trahe
306f546c1edSFiona Trahe    qat_c62x               5626  0
307f546c1edSFiona Trahe    intel_qat              82336  1 qat_c62x
308f546c1edSFiona Trahe
309f546c1edSFiona TraheNext, you need to expose the Virtual Functions (VFs) using the sysfs file system.
310f546c1edSFiona Trahe
311f546c1edSFiona TraheFirst find the BDFs (Bus-Device-Function) of the physical functions (PFs) of
312f546c1edSFiona Traheyour device, e.g.::
313f546c1edSFiona Trahe
314f546c1edSFiona Trahe    lspci -d:37c8
315f546c1edSFiona Trahe
316f546c1edSFiona TraheYou should see output similar to::
317f546c1edSFiona Trahe
318f546c1edSFiona Trahe    1a:00.0 Co-processor: Intel Corporation Device 37c8
319f546c1edSFiona Trahe    3d:00.0 Co-processor: Intel Corporation Device 37c8
320f546c1edSFiona Trahe    3f:00.0 Co-processor: Intel Corporation Device 37c8
321f546c1edSFiona Trahe
322f546c1edSFiona TraheEnable the VFs for each PF by echoing the number of VFs per PF to the pci driver::
323f546c1edSFiona Trahe
324f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:1a:00.0/sriov_numvfs
325f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3d:00.0/sriov_numvfs
326f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3f:00.0/sriov_numvfs
327f546c1edSFiona Trahe
328f546c1edSFiona TraheCheck that the VFs are available for use. For example ``lspci -d:37c9`` should
329f546c1edSFiona Trahelist 48 VF devices available for a ``C62x`` device.
330f546c1edSFiona Trahe
331f546c1edSFiona TraheTo complete the installation follow the instructions in
332f546c1edSFiona Trahe`Binding the available VFs to the DPDK UIO driver`_.
333f546c1edSFiona Trahe
334f546c1edSFiona Trahe.. Note::
335f546c1edSFiona Trahe
336f546c1edSFiona Trahe   If the QAT kernel modules are not loaded and you see an error like ``Failed
337f546c1edSFiona Trahe   to load MMP firmware qat_895xcc_mmp.bin`` in kernel logs, this may be as a
338f546c1edSFiona Trahe   result of not using a distribution, but just updating the kernel directly.
339f546c1edSFiona Trahe
340f546c1edSFiona Trahe   Download firmware from the `kernel firmware repo
341f546c1edSFiona Trahe   <http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/>`_.
342f546c1edSFiona Trahe
343f546c1edSFiona Trahe   Copy qat binaries to ``/lib/firmware``::
344f546c1edSFiona Trahe
345f546c1edSFiona Trahe      cp qat_895xcc.bin /lib/firmware
346f546c1edSFiona Trahe      cp qat_895xcc_mmp.bin /lib/firmware
347f546c1edSFiona Trahe
348f546c1edSFiona Trahe   Change to your linux source root directory and start the qat kernel modules::
349f546c1edSFiona Trahe
350f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_common/intel_qat.ko
351f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_dh895xcc/qat_dh895xcc.ko
352f546c1edSFiona Trahe
353f546c1edSFiona Trahe
354f546c1edSFiona Trahe.. Note::
355f546c1edSFiona Trahe
356f546c1edSFiona Trahe   If you see the following warning in ``/var/log/messages`` it can be ignored:
357f546c1edSFiona Trahe   ``IOMMU should be enabled for SR-IOV to work correctly``.
358ae20c073SDeepak Kumar Jain
3591703e94aSDeclan Doherty
3601703e94aSDeclan DohertyInstallation using 01.org QAT driver
36159ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3621703e94aSDeclan Doherty
3631703e94aSDeclan DohertyDownload the latest QuickAssist Technology Driver from `01.org
364f546c1edSFiona Trahe<https://01.org/packet-processing/intel%C2%AE-quickassist-technology-drivers-and-patches>`_.
3651703e94aSDeclan DohertyConsult the *Getting Started Guide* at the same URL for further information.
3661703e94aSDeclan Doherty
3671703e94aSDeclan DohertyThe steps below assume you are:
3681703e94aSDeclan Doherty
369bb44fb6fSFiona Trahe* Building on a platform with one ``C62x`` device.
370bb44fb6fSFiona Trahe* Using package ``qat1.7.l.4.2.0-000xx.tar.gz``.
371bb44fb6fSFiona Trahe* On Fedora26 kernel ``4.11.11-300.fc26.x86_64``.
3721703e94aSDeclan Doherty
3731703e94aSDeclan DohertyIn the BIOS ensure that SRIOV is enabled and VT-d is disabled.
3741703e94aSDeclan Doherty
3751703e94aSDeclan DohertyUninstall any existing QAT driver, for example by running:
3761703e94aSDeclan Doherty
3771703e94aSDeclan Doherty* ``./installer.sh uninstall`` in the directory where originally installed.
3781703e94aSDeclan Doherty
3791703e94aSDeclan Doherty
3801703e94aSDeclan DohertyBuild and install the SRIOV-enabled QAT driver::
3811703e94aSDeclan Doherty
3821703e94aSDeclan Doherty    mkdir /QAT
3831703e94aSDeclan Doherty    cd /QAT
384f546c1edSFiona Trahe
385bb44fb6fSFiona Trahe    # Copy the package to this location and unpack
386bb44fb6fSFiona Trahe    tar zxof qat1.7.l.4.2.0-000xx.tar.gz
3871703e94aSDeclan Doherty
388bb44fb6fSFiona Trahe    ./configure --enable-icp-sriov=host
389bb44fb6fSFiona Trahe    make install
3901703e94aSDeclan Doherty
391bb44fb6fSFiona TraheYou can use ``cat /sys/kernel/debug/qat<your device type and bdf>/version/fw`` to confirm the driver is correctly installed and is using firmware version 4.2.0.
392bb44fb6fSFiona TraheYou can use ``lspci -d:37c9`` to confirm the presence of the 16 VF devices available per ``C62x`` PF.
393bb44fb6fSFiona Trahe
394bb44fb6fSFiona TraheConfirm the driver is correctly installed and is using firmware version 4.2.0::
395bb44fb6fSFiona Trahe
396bb44fb6fSFiona Trahe    cat /sys/kernel/debug/qat<your device type and bdf>/version/fw
397bb44fb6fSFiona Trahe
398bb44fb6fSFiona Trahe
399bb44fb6fSFiona TraheConfirm the presence of 48 VF devices - 16 per PF::
400bb44fb6fSFiona Trahe
401bb44fb6fSFiona Trahe    lspci -d:37c9
402bb44fb6fSFiona Trahe
4031703e94aSDeclan Doherty
4041703e94aSDeclan DohertyTo complete the installation - follow instructions in `Binding the available VFs to the DPDK UIO driver`_.
4051703e94aSDeclan Doherty
406f546c1edSFiona Trahe.. Note::
407f546c1edSFiona Trahe
408f546c1edSFiona Trahe   If using a later kernel and the build fails with an error relating to
409f546c1edSFiona Trahe   ``strict_stroul`` not being available apply the following patch:
4101703e94aSDeclan Doherty
4111703e94aSDeclan Doherty   .. code-block:: diff
4121703e94aSDeclan Doherty
4131703e94aSDeclan Doherty      /QAT/QAT1.6/quickassist/utilities/downloader/Target_CoreLibs/uclo/include/linux/uclo_platform.h
4141703e94aSDeclan Doherty      + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,5)
4151703e94aSDeclan Doherty      + #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (kstrtoul((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
4161703e94aSDeclan Doherty      + #else
4171703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
4181703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (strict_strtoull((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
4191703e94aSDeclan Doherty      #else
4201703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
4211703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; strict_strtoll((str), (base), (num));}
4221703e94aSDeclan Doherty      #else
4231703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr)                                 \
4241703e94aSDeclan Doherty           do {                                                               \
4251703e94aSDeclan Doherty                 if (str[0] == '-')                                           \
4261703e94aSDeclan Doherty                 {                                                            \
4271703e94aSDeclan Doherty                      *(num) = -(simple_strtoull((str+1), &(endPtr), (base))); \
4281703e94aSDeclan Doherty                 }else {                                                      \
4291703e94aSDeclan Doherty                      *(num) = simple_strtoull((str), &(endPtr), (base));      \
4301703e94aSDeclan Doherty                 }                                                            \
4311703e94aSDeclan Doherty           } while(0)
4321703e94aSDeclan Doherty      + #endif
4331703e94aSDeclan Doherty      #endif
4341703e94aSDeclan Doherty      #endif
4351703e94aSDeclan Doherty
4361703e94aSDeclan Doherty
437f546c1edSFiona Trahe.. Note::
4381703e94aSDeclan Doherty
439f546c1edSFiona Trahe   If the build fails due to missing header files you may need to do following::
4401703e94aSDeclan Doherty
441f546c1edSFiona Trahe      sudo yum install zlib-devel
442f546c1edSFiona Trahe      sudo yum install openssl-devel
443bb44fb6fSFiona Trahe      sudo yum install libudev-devel
4441703e94aSDeclan Doherty
445f546c1edSFiona Trahe.. Note::
4461703e94aSDeclan Doherty
447f546c1edSFiona Trahe   If the build or install fails due to mismatching kernel sources you may need to do the following::
4481703e94aSDeclan Doherty
449f546c1edSFiona Trahe      sudo yum install kernel-headers-`uname -r`
450f546c1edSFiona Trahe      sudo yum install kernel-src-`uname -r`
451f546c1edSFiona Trahe      sudo yum install kernel-devel-`uname -r`
4521703e94aSDeclan Doherty
453f2f639c6SDeepak Kumar Jain
4541703e94aSDeclan DohertyBinding the available VFs to the DPDK UIO driver
45559ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4561703e94aSDeclan Doherty
457f546c1edSFiona TraheUnbind the VFs from the stock driver so they can be bound to the uio driver.
4581703e94aSDeclan Doherty
459f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology DH895xCC device
46059ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
461f546c1edSFiona Trahe
462f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``03:01.00-03:04.07``, if your
463f546c1edSFiona TraheVFs are different adjust the unbind command below::
4641703e94aSDeclan Doherty
4651703e94aSDeclan Doherty    for device in $(seq 1 4); do \
4661703e94aSDeclan Doherty        for fn in $(seq 0 7); do \
4671703e94aSDeclan Doherty            echo -n 0000:03:0${device}.${fn} > \
4681703e94aSDeclan Doherty            /sys/bus/pci/devices/0000\:03\:0${device}.${fn}/driver/unbind; \
4691703e94aSDeclan Doherty        done; \
4701703e94aSDeclan Doherty    done
4711703e94aSDeclan Doherty
472f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology C62x device
47359ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4741703e94aSDeclan Doherty
475f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``1a:01.00-1a:02.07``,
476f546c1edSFiona Trahe``3d:01.00-3d:02.07`` and ``3f:01.00-3f:02.07``, if your VFs are different
477f546c1edSFiona Traheadjust the unbind command below::
478ae20c073SDeepak Kumar Jain
479ae20c073SDeepak Kumar Jain    for device in $(seq 1 2); do \
480ae20c073SDeepak Kumar Jain        for fn in $(seq 0 7); do \
481ae20c073SDeepak Kumar Jain            echo -n 0000:1a:0${device}.${fn} > \
482ae20c073SDeepak Kumar Jain            /sys/bus/pci/devices/0000\:1a\:0${device}.${fn}/driver/unbind; \
483ae20c073SDeepak Kumar Jain
484ae20c073SDeepak Kumar Jain            echo -n 0000:3d:0${device}.${fn} > \
485ae20c073SDeepak Kumar Jain            /sys/bus/pci/devices/0000\:3d\:0${device}.${fn}/driver/unbind; \
486ae20c073SDeepak Kumar Jain
487ae20c073SDeepak Kumar Jain            echo -n 0000:3f:0${device}.${fn} > \
488ae20c073SDeepak Kumar Jain            /sys/bus/pci/devices/0000\:3f\:0${device}.${fn}/driver/unbind; \
489ae20c073SDeepak Kumar Jain        done; \
490ae20c073SDeepak Kumar Jain    done
491ae20c073SDeepak Kumar Jain
492259310f3SFiona TraheFor Intel(R) QuickAssist Technology C3xxx or D15xx device
49359ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
494ae20c073SDeepak Kumar Jain
495f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``01:01.00-01:02.07``, if your
496f546c1edSFiona TraheVFs are different adjust the unbind command below::
497f2f639c6SDeepak Kumar Jain
498f2f639c6SDeepak Kumar Jain    for device in $(seq 1 2); do \
499f2f639c6SDeepak Kumar Jain        for fn in $(seq 0 7); do \
500f2f639c6SDeepak Kumar Jain            echo -n 0000:01:0${device}.${fn} > \
501f2f639c6SDeepak Kumar Jain            /sys/bus/pci/devices/0000\:01\:0${device}.${fn}/driver/unbind; \
502f2f639c6SDeepak Kumar Jain        done; \
503f2f639c6SDeepak Kumar Jain    done
504f2f639c6SDeepak Kumar Jain
505f546c1edSFiona TraheBind to the DPDK uio driver
50659ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^
507f2f639c6SDeepak Kumar Jain
508f546c1edSFiona TraheInstall the DPDK igb_uio driver, bind the VF PCI Device id to it and use lspci
509f546c1edSFiona Traheto confirm the VF devices are now in use by igb_uio kernel driver,
510f546c1edSFiona Trahee.g. for the C62x device::
511f546c1edSFiona Trahe
512f546c1edSFiona Trahe    cd to the top-level DPDK directory
513f546c1edSFiona Trahe    modprobe uio
514f546c1edSFiona Trahe    insmod ./build/kmod/igb_uio.ko
515f546c1edSFiona Trahe    echo "8086 37c9" > /sys/bus/pci/drivers/igb_uio/new_id
516f546c1edSFiona Trahe    lspci -vvd:37c9
517cb4a1d14SEoin Breen
518cb4a1d14SEoin Breen
519f546c1edSFiona TraheAnother way to bind the VFs to the DPDK UIO driver is by using the
520f546c1edSFiona Trahe``dpdk-devbind.py`` script::
521cb4a1d14SEoin Breen
522f546c1edSFiona Trahe    cd to the top-level DPDK directory
523c6dab2a8SThomas Monjalon    ./usertools/dpdk-devbind.py -b igb_uio 0000:03:01.1
5249333cfbaSPablo de Lara
525b1c9177bSFiona TraheTesting
526b1c9177bSFiona Trahe~~~~~~~
527b1c9177bSFiona Trahe
528b1c9177bSFiona TraheQAT crypto PMD can be tested by running the test application::
529b1c9177bSFiona Trahe
530b1c9177bSFiona Trahe    make defconfig
531b1c9177bSFiona Trahe    make test-build -j
532b1c9177bSFiona Trahe    cd ./build/app
533b1c9177bSFiona Trahe    ./test -l1 -n1 -w <your qat bdf>
534b1c9177bSFiona Trahe    RTE>>cryptodev_qat_autotest
535b1c9177bSFiona Trahe
536b1c9177bSFiona TraheQAT compression PMD can be tested by running the test application::
537b1c9177bSFiona Trahe
538b1c9177bSFiona Trahe    make defconfig
539b1c9177bSFiona Trahe    sed -i 's,\(CONFIG_RTE_COMPRESSDEV_TEST\)=n,\1=y,' build/.config
540b1c9177bSFiona Trahe    make test-build -j
541b1c9177bSFiona Trahe    cd ./build/app
542b1c9177bSFiona Trahe    ./test -l1 -n1 -w <your qat bdf>
543b1c9177bSFiona Trahe    RTE>>compressdev_autotest
544b1c9177bSFiona Trahe
5459333cfbaSPablo de Lara
5465394c11dSFiona TraheDebugging
54759ad25feSFiona Trahe~~~~~~~~~
5485394c11dSFiona Trahe
5495394c11dSFiona TraheThere are 2 sets of trace available via the dynamic logging feature:
5505394c11dSFiona Trahe
5515394c11dSFiona Trahe* pmd.qat_dp exposes trace on the data-path.
5525394c11dSFiona Trahe* pmd.qat_general exposes all other trace.
5535394c11dSFiona Trahe
5545394c11dSFiona Trahepmd.qat exposes both sets of traces.
5555394c11dSFiona TraheThey can be enabled using the log-level option (where 8=maximum log level) on
5565394c11dSFiona Trahethe process cmdline, e.g. using any of the following::
5575394c11dSFiona Trahe
5585394c11dSFiona Trahe    --log-level="pmd.qat_general,8"
5595394c11dSFiona Trahe    --log-level="pmd.qat_dp,8"
5605394c11dSFiona Trahe    --log-level="pmd.qat,8"
5615394c11dSFiona Trahe
5625394c11dSFiona Trahe.. Note::
5635394c11dSFiona Trahe
5645394c11dSFiona Trahe    The global RTE_LOG_DP_LEVEL overrides data-path trace so must be set to
5655394c11dSFiona Trahe    RTE_LOG_DEBUG to see all the trace. This variable is in config/rte_config.h
5665394c11dSFiona Trahe    for meson build and config/common_base for gnu make.
5675394c11dSFiona Trahe    Also the dynamic global log level overrides both sets of trace, so e.g. no
5685394c11dSFiona Trahe    QAT trace would display in this case::
5695394c11dSFiona Trahe
5705394c11dSFiona Trahe	--log-level="7" --log-level="pmd.qat_general,8"
571