xref: /dpdk/doc/guides/cryptodevs/qat.rst (revision 3a80d7fb2ecdd6e8e48e56e3726b26980fa2a089)
15630257fSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
27d5ef3bbSDamian Nowak    Copyright(c) 2015-2019 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
9bfd84d7eSArek Kusztal* Details of the symmetric and asymmetric crypto services below.
1043628b3dSDavid Marchand* Details of the :doc:`compression service <../compressdevs/qat_comp>`
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
19bfd84d7eSArek KusztalThe QAT symmetric crypto PMD (hereafter referred to as `QAT SYM [PMD]`) provides
20bfd84d7eSArek Kusztalpoll mode crypto driver support for the following hardware accelerator devices:
21f546c1edSFiona Trahe
22f546c1edSFiona Trahe* ``Intel QuickAssist Technology DH895xCC``
23f546c1edSFiona Trahe* ``Intel QuickAssist Technology C62x``
24f546c1edSFiona Trahe* ``Intel QuickAssist Technology C3xxx``
257b08003bSAdam Dybkowski* ``Intel QuickAssist Technology 200xx``
26259310f3SFiona Trahe* ``Intel QuickAssist Technology D15xx``
27cb440babSAdam Dybkowski* ``Intel QuickAssist Technology C4xxx``
288f393c4fSArek Kusztal* ``Intel QuickAssist Technology 4xxx``
291703e94aSDeclan Doherty
301703e94aSDeclan Doherty
311703e94aSDeclan DohertyFeatures
3259ad25feSFiona Trahe~~~~~~~~
331703e94aSDeclan Doherty
34bfd84d7eSArek KusztalThe QAT SYM PMD has support for:
351703e94aSDeclan Doherty
361703e94aSDeclan DohertyCipher algorithms:
371703e94aSDeclan Doherty
38e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CBC``
39e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CTR``
40fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CBC``
41fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CBC``
42fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CBC``
43fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CTR``
44fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CTR``
45fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CTR``
467d5ef3bbSDamian Nowak* ``RTE_CRYPTO_CIPHER_AES_XTS``
47fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
48db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_NULL``
49d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
506cd8b4d8SArek Kusztal* ``RTE_CRYPTO_CIPHER_DES_CBC``
51d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_AES_DOCSISBPI``
52d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_DES_DOCSISBPI``
53d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``
541703e94aSDeclan Doherty
551703e94aSDeclan DohertyHash algorithms:
561703e94aSDeclan Doherty
576e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA1``
581703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
596e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA224``
60ebdbe12fSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
616e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA256``
621703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
636e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA384``
64d905ee32SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
656e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA512``
661703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
67*3a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_224``
68*3a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_256``
69*3a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_384``
70*3a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_512``
711703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
72a38dfe97SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SNOW3G_UIA2``
7361ec5181SArek Kusztal* ``RTE_CRYPTO_AUTH_MD5_HMAC``
74db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_NULL``
75d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_KASUMI_F9``
762fa64f84SArek Kusztal* ``RTE_CRYPTO_AUTH_AES_GMAC``
77d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_AUTH_ZUC_EIA3``
7891c1daa4STomasz Cel* ``RTE_CRYPTO_AUTH_AES_CMAC``
791703e94aSDeclan Doherty
80b79e4c00SPablo de LaraSupported AEAD algorithms:
81655c901bSAndrea Grandi
82b79e4c00SPablo de Lara* ``RTE_CRYPTO_AEAD_AES_GCM``
837bd6f76eSTomasz Cel* ``RTE_CRYPTO_AEAD_AES_CCM``
84faa57df0SArek Kusztal* ``RTE_CRYPTO_AEAD_CHACHA20_POLY1305``
85b79e4c00SPablo de Lara
866f0ef237SDavid CoyleProtocol offloads:
876f0ef237SDavid Coyle
886f0ef237SDavid Coyle* ``RTE_SECURITY_PROTOCOL_DOCSIS``
891703e94aSDeclan Doherty
90bcd7e3e8SAdam DybkowskiSupported Chains
91bcd7e3e8SAdam Dybkowski~~~~~~~~~~~~~~~~
92bcd7e3e8SAdam Dybkowski
93bcd7e3e8SAdam DybkowskiAll the usual chains are supported and also some mixed chains:
94bcd7e3e8SAdam Dybkowski
95bcd7e3e8SAdam Dybkowski.. table:: Supported hash-cipher chains for wireless digest-encrypted cases
96bcd7e3e8SAdam Dybkowski
97bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
98bcd7e3e8SAdam Dybkowski   | Cipher algorithm | NULL AUTH | SNOW3G UIA2 | ZUC EIA3 | AES CMAC |
99bcd7e3e8SAdam Dybkowski   +==================+===========+=============+==========+==========+
100a1598e90SAdam Dybkowski   | NULL CIPHER      | Y         | 2&3         | 2&3      | Y        |
101bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
1028f393c4fSArek Kusztal   | SNOW3G UEA2      | 2&3       | 1&2&3       | 2&3      | 2&3      |
103bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
104a1598e90SAdam Dybkowski   | ZUC EEA3         | 2&3       | 2&3         | 2&3      | 2&3      |
105bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
1068f393c4fSArek Kusztal   | AES CTR          | 1&2&3     | 2&3         | 2&3      | Y        |
107bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
108bcd7e3e8SAdam Dybkowski
109bcd7e3e8SAdam Dybkowski* The combinations marked as "Y" are supported on all QAT hardware versions.
1108f393c4fSArek Kusztal* The combinations marked as "2&3" are supported on GEN2 and GEN3 QAT hardware only.
1118f393c4fSArek Kusztal* The combinations marked as "1&2&3" are supported on GEN1, GEN2 and GEN3 QAT hardware only.
112bcd7e3e8SAdam Dybkowski
113bcd7e3e8SAdam Dybkowski
1141703e94aSDeclan DohertyLimitations
11559ad25feSFiona Trahe~~~~~~~~~~~
1161703e94aSDeclan Doherty
1171703e94aSDeclan Doherty* Only supports the session-oriented API implementation (session-less APIs are not supported).
1182142e6dcSPablo de Lara* SNOW 3G (UEA2), KASUMI (F8) and ZUC (EEA3) supported only if cipher length and offset fields are byte-multiple.
1199333cfbaSPablo de Lara* SNOW 3G (UIA2) and ZUC (EIA3) supported only if hash length and offset fields are byte-multiple.
1208831895bSFiona Trahe* No BSD support as BSD QAT kernel driver not available.
121d9b7d5bbSArek Kusztal* ZUC EEA3/EIA3 is not supported by dh895xcc devices
1222a7bb4fdSFiona 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.
123026f21c0SFiona Trahe* Queue-pairs are thread-safe on Intel CPUs but Queues are not (that is, within a single
124026f21c0SFiona Trahe  queue-pair all enqueues to the TX queue must be done from one thread and all dequeues
125026f21c0SFiona Trahe  from the RX queue must be done from one thread, but enqueues and dequeues may be done
126026f21c0SFiona Trahe  in different threads.)
127aa983f03SAdam Dybkowski* A GCM limitation exists, but only in the case where there are multiple
128aa983f03SAdam Dybkowski  generations of QAT devices on a single platform.
129aa983f03SAdam Dybkowski  To optimise performance, the GCM crypto session should be initialised for the
130aa983f03SAdam Dybkowski  device generation to which the ops will be enqueued. Specifically if a GCM
131aa983f03SAdam Dybkowski  session is initialised on a GEN2 device, but then attached to an op enqueued
132aa983f03SAdam Dybkowski  to a GEN3 device, it will work but cannot take advantage of hardware
133aa983f03SAdam Dybkowski  optimisations in the GEN3 device. And if a GCM session is initialised on a
134aa983f03SAdam Dybkowski  GEN3 device, then attached to an op sent to a GEN1/GEN2 device, it will not be
135aa983f03SAdam Dybkowski  enqueued to the device and will be marked as failed. The simplest way to
136db27370bSStephen Hemminger  mitigate this is to use the PCI allowlist to avoid mixing devices of different
137aa983f03SAdam Dybkowski  generations in the same process if planning to use for GCM.
138a1598e90SAdam Dybkowski* The mixed algo feature on GEN2 is not supported by all kernel drivers. Check
139a1598e90SAdam Dybkowski  the notes under the Available Kernel Drivers table below for specific details.
1406f0ef237SDavid Coyle* Out-of-place is not supported for combined Crypto-CRC DOCSIS security
1416f0ef237SDavid Coyle  protocol.
1426f0ef237SDavid Coyle* ``RTE_CRYPTO_CIPHER_DES_DOCSISBPI`` is not supported for combined Crypto-CRC
1436f0ef237SDavid Coyle  DOCSIS security protocol.
1446b048cdfSDavid Coyle* Multi-segment buffers are not supported for combined Crypto-CRC DOCSIS
1456b048cdfSDavid Coyle  security protocol.
1461703e94aSDeclan Doherty
147bb44fb6fSFiona TraheExtra notes on KASUMI F9
14859ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
1491703e94aSDeclan Doherty
150bb44fb6fSFiona TraheWhen using KASUMI F9 authentication algorithm, the input buffer must be
151aa38c849SFiona Traheconstructed according to the
152aa38c849SFiona Trahe`3GPP KASUMI specification <http://cryptome.org/3gpp/35201-900.pdf>`_
153aa38c849SFiona Trahe(section 4.4, page 13). The input buffer has to have COUNT (4 bytes),
154aa38c849SFiona TraheFRESH (4 bytes), MESSAGE and DIRECTION (1 bit) concatenated. After the DIRECTION
155aa38c849SFiona Trahebit, a single '1' bit is appended, followed by between 0 and 7 '0' bits, so that
156aa38c849SFiona Trahethe total length of the buffer is multiple of 8 bits. Note that the actual
157aa38c849SFiona Trahemessage can be any length, specified in bits.
158bb44fb6fSFiona Trahe
159bb44fb6fSFiona TraheOnce this buffer is passed this way, when creating the crypto operation,
160aa38c849SFiona Trahelength of data to authenticate "op.sym.auth.data.length" must be the length
161bb44fb6fSFiona Traheof all the items described above, including the padding at the end.
162aa38c849SFiona TraheAlso, offset of data to authenticate "op.sym.auth.data.offset"
163bb44fb6fSFiona Trahemust be such that points at the start of the COUNT bytes.
164bb44fb6fSFiona Trahe
165f81cbc20SArek KusztalAsymmetric Crypto Service on QAT
166f81cbc20SArek Kusztal--------------------------------
167bb44fb6fSFiona Trahe
168bfd84d7eSArek KusztalThe QAT asymmetric crypto PMD (hereafter referred to as `QAT ASYM [PMD]`) provides
169bfd84d7eSArek Kusztalpoll mode crypto driver support for the following hardware accelerator devices:
170f81cbc20SArek Kusztal
171bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology DH895xCC``
172bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology C62x``
173bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology C3xxx``
174bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology D15xx``
175efb1a06bSArek Kusztal* ``Intel QuickAssist Technology 4xxx``
17683ce3b39SBrian Dooley* ``Intel QuickAssist Technology 401xxx``
177bfd84d7eSArek Kusztal
178bfd84d7eSArek KusztalThe QAT ASYM PMD has support for:
179bfd84d7eSArek Kusztal
180bfd84d7eSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
181bfd84d7eSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_MODINV``
1823b78aa7bSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_RSA``
183b5324d38SArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECDSA``
1846c25a68aSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECPM``
185305e1f85SArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECDH``
186fb70b33bSArek Kusztal
187f81cbc20SArek KusztalLimitations
188f81cbc20SArek Kusztal~~~~~~~~~~~
189bb44fb6fSFiona Trahe
190bfd84d7eSArek Kusztal* Big integers longer than 4096 bits are not supported.
191026f21c0SFiona Trahe* Queue-pairs are thread-safe on Intel CPUs but Queues are not (that is, within a single
192026f21c0SFiona Trahe  queue-pair all enqueues to the TX queue must be done from one thread and all dequeues
193026f21c0SFiona Trahe  from the RX queue must be done from one thread, but enqueues and dequeues may be done
194026f21c0SFiona Trahe  in different threads.)
195e2c5f4eaSArek Kusztal* RSA-2560, RSA-3584 are not supported
196bfd84d7eSArek Kusztal
19759ad25feSFiona Trahe.. _building_qat:
19859ad25feSFiona Trahe
19959ad25feSFiona TraheBuilding PMDs on QAT
20059ad25feSFiona Trahe--------------------
201bb44fb6fSFiona Trahe
20202545b6cSFiona TraheA QAT device can host multiple acceleration services:
20302545b6cSFiona Trahe
20402545b6cSFiona Trahe* symmetric cryptography
20502545b6cSFiona Trahe* data compression
206f81cbc20SArek Kusztal* asymmetric cryptography
20702545b6cSFiona Trahe
20802545b6cSFiona TraheThese services are provided to DPDK applications via PMDs which register to
20902545b6cSFiona Traheimplement the corresponding cryptodev and compressdev APIs. The PMDs use
21002545b6cSFiona Trahecommon QAT driver code which manages the QAT PCI device. They also depend on a
21102545b6cSFiona TraheQAT kernel driver being installed on the platform, see :ref:`qat_kernel` below.
2121703e94aSDeclan Doherty
213bb44fb6fSFiona Trahe
21402545b6cSFiona TraheConfiguring and Building the DPDK QAT PMDs
21502545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21602545b6cSFiona Trahe
21702545b6cSFiona Trahe
21802545b6cSFiona TraheFurther information on configuring, building and installing DPDK is described
21943628b3dSDavid Marchand:doc:`here <../linux_gsg/build_dpdk>`.
22002545b6cSFiona Trahe
2215f40555bSTomasz Jozwiak.. _building_qat_config:
2225f40555bSTomasz Jozwiak
2237ce27b9eSFiona TraheBuild Configuration
2247ce27b9eSFiona Trahe~~~~~~~~~~~~~~~~~~~
2257ce27b9eSFiona Trahe
2267ce27b9eSFiona TraheThese are the build configuration options affecting QAT, and their default values:
2277ce27b9eSFiona Trahe
2287ce27b9eSFiona Trahe.. code-block:: console
2297ce27b9eSFiona Trahe
230fd5f9fb9SCiara Power	RTE_PMD_QAT_MAX_PCI_DEVICES=48
231fd5f9fb9SCiara Power	RTE_PMD_QAT_COMP_IM_BUFFER_SIZE=65536
2327ce27b9eSFiona Trahe
233bfd84d7eSArek KusztalBoth QAT SYM PMD and QAT ASYM PMD have an external dependency on libcrypto, so are not
234fd5f9fb9SCiara Powerbuilt by default.
2357ce27b9eSFiona Trahe
236fd5f9fb9SCiara PowerThe QAT compressdev PMD has no external dependencies, so is built by default.
2377ce27b9eSFiona Trahe
2387ce27b9eSFiona TraheThe number of VFs per PF varies - see table below. If multiple QAT packages are
239fd5f9fb9SCiara Powerinstalled on a platform then RTE_PMD_QAT_MAX_PCI_DEVICES should be
2407ce27b9eSFiona Traheadjusted to the number of VFs which the QAT common code will need to handle.
241bfd84d7eSArek Kusztal
242bfd84d7eSArek Kusztal.. Note::
243bfd84d7eSArek Kusztal
244bfd84d7eSArek Kusztal        There are separate config items (not QAT-specific) for max cryptodevs
245fd5f9fb9SCiara Power        RTE_CRYPTO_MAX_DEVS and max compressdevs RTE_COMPRESS_MAX_DEVS,
246bfd84d7eSArek Kusztal        if necessary these should be adjusted to handle the total of QAT and other
247bfd84d7eSArek Kusztal        devices which the process will use. In particular for crypto, where each
248bfd84d7eSArek Kusztal        QAT VF may expose two crypto devices, sym and asym, it may happen that the
249bfd84d7eSArek Kusztal        number of devices will be bigger than MAX_DEVS and the process will show an error
250fd5f9fb9SCiara Power        during PMD initialisation. To avoid this problem RTE_CRYPTO_MAX_DEVS may be
251db27370bSStephen Hemminger        increased or -a, allow domain:bus:devid:func option may be used.
252bfd84d7eSArek Kusztal
2537ce27b9eSFiona Trahe
2544e8f2d6aSFiona TraheQAT compression PMD needs intermediate buffers to support Deflate compression
255fd5f9fb9SCiara Powerwith Dynamic Huffman encoding. RTE_PMD_QAT_COMP_IM_BUFFER_SIZE
2564e8f2d6aSFiona Trahespecifies the size of a single buffer, the PMD will allocate a multiple of these,
2575f40555bSTomasz Jozwiakplus some extra space for associated meta-data. For GEN2 devices, 20 buffers are
2585f40555bSTomasz Jozwiakallocated while for GEN1 devices, 12 buffers are allocated, plus 1472 bytes overhead.
2594e8f2d6aSFiona Trahe
2604e8f2d6aSFiona Trahe.. Note::
2614e8f2d6aSFiona Trahe
2624e8f2d6aSFiona Trahe	If the compressed output of a Deflate operation using Dynamic Huffman
2634e8f2d6aSFiona Trahe	Encoding is too big to fit in an intermediate buffer, then the
264c13cecf6SAdam Dybkowski	operation will be split into smaller operations and their results will
265c13cecf6SAdam Dybkowski	be merged afterwards.
266c13cecf6SAdam Dybkowski	This is not possible if any checksum calculation was requested - in such
267c13cecf6SAdam Dybkowski	case the code falls back to fixed compression.
268a720e674STomasz Jozwiak	To avoid this less performant case, applications should configure
269a720e674STomasz Jozwiak	the intermediate buffer size to be larger than the expected input data size
270a720e674STomasz Jozwiak	(compressed output size is usually unknown, so the only option is to make
271a720e674STomasz Jozwiak	larger than the input size).
2724e8f2d6aSFiona Trahe
273bb44fb6fSFiona Trahe
27447c3f7a4SArek KusztalRunning QAT PMD with minimum threshold for burst size
27547c3f7a4SArek Kusztal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27647c3f7a4SArek Kusztal
27747c3f7a4SArek KusztalIf only a small number or packets can be enqueued. Each enqueue causes an expensive MMIO write.
27847c3f7a4SArek KusztalThese MMIO write occurrences can be optimised by setting any of the following parameters:
27947c3f7a4SArek Kusztal
28047c3f7a4SArek Kusztal- qat_sym_enq_threshold
28147c3f7a4SArek Kusztal- qat_asym_enq_threshold
28247c3f7a4SArek Kusztal- qat_comp_enq_threshold
28347c3f7a4SArek Kusztal
28447c3f7a4SArek KusztalWhen any of these parameters is set rte_cryptodev_enqueue_burst function will
28547c3f7a4SArek Kusztalreturn 0 (thereby avoiding an MMIO) if the device is congested and number of packets
28647c3f7a4SArek Kusztalpossible to enqueue is smaller.
28747c3f7a4SArek KusztalTo use this feature the user must set the parameter on process start as a device additional parameter::
28847c3f7a4SArek Kusztal
289db27370bSStephen Hemminger  -a 03:01.1,qat_sym_enq_threshold=32,qat_comp_enq_threshold=16
29047c3f7a4SArek Kusztal
29147c3f7a4SArek KusztalAll parameters can be used with the same device regardless of order. Parameters are separated
29247c3f7a4SArek Kusztalby comma. When the same parameter is used more than once first occurrence of the parameter
29347c3f7a4SArek Kusztalis used.
29447c3f7a4SArek KusztalMaximum threshold that can be set is 32.
29547c3f7a4SArek Kusztal
2963227bc71SKai JiRunning QAT PMD with Intel IPSEC MB library for symmetric precomputes function
2973227bc71SKai Ji~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2983227bc71SKai Ji
2993227bc71SKai JiThe QAT PMD use Openssl library for partial hash calculation in symmetirc precomputes function by
3003227bc71SKai Jidefault, the following parameter is allow QAT PMD switch over to multi-buffer job API if Intel
3013227bc71SKai JiIPSEC MB library installed on system.
3023227bc71SKai Ji
3033227bc71SKai Ji- qat_ipsec_mb_lib
3043227bc71SKai Ji
3053227bc71SKai JiTo use this feature the user must set the parameter on process start as a device additional parameter::
3063227bc71SKai Ji
3073227bc71SKai Ji  -a 03:01.1,qat_ipsec_mb_lib=1
3083227bc71SKai Ji
30947c3f7a4SArek Kusztal
310bb44fb6fSFiona TraheDevice and driver naming
31159ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
312bb44fb6fSFiona Trahe
313bfd84d7eSArek Kusztal* The qat cryptodev symmetric crypto driver name is "crypto_qat".
314bfd84d7eSArek Kusztal* The qat cryptodev asymmetric crypto driver name is "crypto_qat_asym".
315bb44fb6fSFiona Trahe
316bfd84d7eSArek KusztalThe "rte_cryptodev_devices_get()" returns the devices exposed by either of these drivers.
317bfd84d7eSArek Kusztal
318bfd84d7eSArek Kusztal* Each qat sym crypto device has a unique name, in format
319aa38c849SFiona Trahe  "<pci bdf>_<service>", e.g. "0000:41:01.0_qat_sym".
320bfd84d7eSArek Kusztal* Each qat asym crypto device has a unique name, in format
321bfd84d7eSArek Kusztal  "<pci bdf>_<service>", e.g. "0000:41:01.0_qat_asym".
322aa38c849SFiona Trahe  This name can be passed to "rte_cryptodev_get_dev_id()" to get the device_id.
323bb44fb6fSFiona Trahe
324bb44fb6fSFiona Trahe.. Note::
325bb44fb6fSFiona Trahe
326bfd84d7eSArek Kusztal	The cryptodev driver name is passed to the dpdk-test-crypto-perf tool in the "-devtype" parameter.
327bb44fb6fSFiona Trahe
32885b00824SAdam Dybkowski	The qat crypto device name is in the format of the worker parameter passed to the crypto scheduler.
329bb44fb6fSFiona Trahe
330df8cca46SFiona Trahe* The qat compressdev driver name is "compress_qat".
331bb44fb6fSFiona Trahe  The rte_compressdev_devices_get() returns the devices exposed by this driver.
332bb44fb6fSFiona Trahe
333bb44fb6fSFiona Trahe* Each qat compression device has a unique name, in format
334bb44fb6fSFiona Trahe  <pci bdf>_<service>, e.g. "0000:41:01.0_qat_comp".
335bb44fb6fSFiona Trahe  This name can be passed to rte_compressdev_get_dev_id() to get the device_id.
336bb44fb6fSFiona Trahe
33702545b6cSFiona Trahe.. _qat_kernel:
33802545b6cSFiona Trahe
33902545b6cSFiona TraheDependency on the QAT kernel driver
34002545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34102545b6cSFiona Trahe
34202545b6cSFiona TraheTo use QAT an SRIOV-enabled QAT kernel driver is required. The VF
34302545b6cSFiona Trahedevices created and initialised by this driver will be used by the QAT PMDs.
34402545b6cSFiona Trahe
34502545b6cSFiona TraheInstructions for installation are below, but first an explanation of the
34602545b6cSFiona Traherelationships between the PF/VF devices and the PMDs visible to
34702545b6cSFiona TraheDPDK applications.
34802545b6cSFiona Trahe
34902545b6cSFiona TraheEach QuickAssist PF device exposes a number of VF devices. Each VF device can
350bfd84d7eSArek Kusztalenable one symmetric cryptodev PMD and/or one asymmetric cryptodev PMD and/or
351bfd84d7eSArek Kusztalone compressdev PMD.
35202545b6cSFiona TraheThese QAT PMDs share the same underlying device and pci-mgmt code, but are
35302545b6cSFiona Traheenumerated independently on their respective APIs and appear as independent
35402545b6cSFiona Trahedevices to applications.
35502545b6cSFiona Trahe
35602545b6cSFiona Trahe.. Note::
35702545b6cSFiona Trahe
35802545b6cSFiona Trahe   Each VF can only be used by one DPDK process. It is not possible to share
35902545b6cSFiona Trahe   the same VF across multiple processes, even if these processes are using
36002545b6cSFiona Trahe   different acceleration services.
36102545b6cSFiona Trahe
36202545b6cSFiona Trahe   Conversely one DPDK process can use one or more QAT VFs and can expose both
36302545b6cSFiona Trahe   cryptodev and compressdev instances on each of those VFs.
36402545b6cSFiona Trahe
365bb44fb6fSFiona Trahe
366bb44fb6fSFiona TraheAvailable kernel drivers
36759ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
368bb44fb6fSFiona Trahe
369ab3dec55SFiona TraheKernel drivers for each device for each service are listed in the following table. (Scroll right
370ab3dec55SFiona Traheto see the full table)
371bb44fb6fSFiona Trahe
3721703e94aSDeclan Doherty
373f546c1edSFiona Trahe.. _table_qat_pmds_drivers:
374f546c1edSFiona Trahe
375f5160653SArek Kusztal.. table:: QAT device generations, devices and drivers
376f546c1edSFiona Trahe
377ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
378ab3dec55SFiona Trahe   | S   | A   | C   | Gen | Device   | Driver/ver    | Kernel Module | Pci Driver | PF Did | #PFs | VF Did | VFs/PF |
379ab3dec55SFiona Trahe   +=====+=====+=====+=====+==========+===============+===============+============+========+======+========+========+
380ab3dec55SFiona Trahe   | Yes | No  | No  | 1   | DH895xCC | linux/4.4+    | qat_dh895xcc  | dh895xcc   | 435    | 1    | 443    | 32     |
381ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
38261a8759cSRebecca Troy   | Yes | Yes | No  | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
383ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
38461a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.13.0+   | "             | "          | "      | "    | "      | "      |
385ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
386ab3dec55SFiona Trahe   | Yes | No  | No  | 2   | C62x     | linux/4.5+    | qat_c62x      | c6xx       | 37c8   | 3    | 37c9   | 16     |
387ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
38861a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
389ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
390ab3dec55SFiona Trahe   | Yes | No  | No  | 2   | C3xxx    | linux/4.5+    | qat_c3xxx     | c3xxx      | 19e2   | 1    | 19e3   | 16     |
391ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
39261a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
393ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
3947b08003bSAdam Dybkowski   | Yes | No  | No  | 2   | 200xx    | p             | qat_200xx     | 200xx      | 18ee   | 1    | 18ef   | 16     |
3957b08003bSAdam Dybkowski   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
39661a8759cSRebecca Troy   | Yes | No  | No  | 2   | D15xx    | p             | qat_d15xx     | d15xx      | 6f54   | 1    | 6f55   | 16     |
397ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
398cb440babSAdam Dybkowski   | Yes | No  | No  | 3   | C4xxx    | p             | qat_c4xxx     | c4xxx      | 18a0   | 1    | 18a1   | 128    |
399ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
40083ce3b39SBrian Dooley   | Yes | Yes | No  | 4   | 4xxx     | linux/5.11+   | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
4018f393c4fSArek Kusztal   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
40283ce3b39SBrian Dooley   | Yes | Yes | Yes | 4   | 4xxx     | linux/5.17+   | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
40383ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
40483ce3b39SBrian Dooley   | Yes | No  | No  | 4   | 4xxx     | IDZ/ N/A      | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
40583ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
40683ce3b39SBrian Dooley   | Yes | Yes | Yes | 4   | 401xxx   | linux/5.19+   | qat_401xxx    | 4xxx       | 4942   | 2    | 4943   | 16     |
40783ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
40883ce3b39SBrian Dooley   | Yes | No  | No  | 4   | 401xxx   | IDZ/ N/A      | qat_401xxx    | 4xxx       | 4942   | 2    | 4943   | 16     |
409f4eac3a0SArek Kusztal   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
410f546c1edSFiona Trahe
41161a8759cSRebecca Troy* Note: Symmetric mixed crypto algorithms feature on Gen 2 works only with IDZ driver version 4.9.0+
412a1598e90SAdam Dybkowski
413ab3dec55SFiona TraheThe first 3 columns indicate the service:
414ab3dec55SFiona Trahe
415ab3dec55SFiona Trahe* S = Symmetric crypto service (via cryptodev API)
416ab3dec55SFiona Trahe* A = Asymmetric crypto service  (via cryptodev API)
417ab3dec55SFiona Trahe* C = Compression service (via compressdev API)
418f546c1edSFiona Trahe
419f546c1edSFiona TraheThe ``Driver`` column indicates either the Linux kernel version in which
42061a8759cSRebecca Troysupport for this device was introduced or a driver available on Intel Developer Zone (IDZ).
42161a8759cSRebecca TroyThere are both linux in-tree and IDZ kernel drivers available for some
422259310f3SFiona Trahedevices. p = release pending.
423f546c1edSFiona Trahe
424f546c1edSFiona TraheIf you are running on a kernel which includes a driver for your device, see
425f546c1edSFiona Trahe`Installation using kernel.org driver`_ below. Otherwise see
42661a8759cSRebecca Troy`Installation using IDZ QAT driver`_.
427f546c1edSFiona Trahe
42883ce3b39SBrian Dooley.. note::
42983ce3b39SBrian Dooley
43083ce3b39SBrian Dooley   The asymmetric service is not supported by DPDK QAT PMD for the Gen 3 platform.
43183ce3b39SBrian Dooley   The actual crypto services enabled on the system depend
43283ce3b39SBrian Dooley   on QAT driver capabilities and hardware slice configuration.
433f546c1edSFiona Trahe
434f546c1edSFiona TraheInstallation using kernel.org driver
43559ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436f546c1edSFiona Trahe
437f546c1edSFiona TraheThe examples below are based on the C62x device, if you have a different device
438f546c1edSFiona Traheuse the corresponding values in the above table.
439f546c1edSFiona Trahe
440f546c1edSFiona TraheIn BIOS ensure that SRIOV is enabled and either:
441f546c1edSFiona Trahe
442f546c1edSFiona Trahe* Disable VT-d or
443f546c1edSFiona Trahe* Enable VT-d and set ``"intel_iommu=on iommu=pt"`` in the grub file.
444f546c1edSFiona Trahe
445f546c1edSFiona TraheCheck that the QAT driver is loaded on your system, by executing::
446f546c1edSFiona Trahe
447f546c1edSFiona Trahe    lsmod | grep qa
448f546c1edSFiona Trahe
449f546c1edSFiona TraheYou should see the kernel module for your device listed, e.g.::
450f546c1edSFiona Trahe
451f546c1edSFiona Trahe    qat_c62x               5626  0
452f546c1edSFiona Trahe    intel_qat              82336  1 qat_c62x
453f546c1edSFiona Trahe
454f546c1edSFiona TraheNext, you need to expose the Virtual Functions (VFs) using the sysfs file system.
455f546c1edSFiona Trahe
456f546c1edSFiona TraheFirst find the BDFs (Bus-Device-Function) of the physical functions (PFs) of
457f546c1edSFiona Traheyour device, e.g.::
458f546c1edSFiona Trahe
459f546c1edSFiona Trahe    lspci -d:37c8
460f546c1edSFiona Trahe
461f546c1edSFiona TraheYou should see output similar to::
462f546c1edSFiona Trahe
463f546c1edSFiona Trahe    1a:00.0 Co-processor: Intel Corporation Device 37c8
464f546c1edSFiona Trahe    3d:00.0 Co-processor: Intel Corporation Device 37c8
465f546c1edSFiona Trahe    3f:00.0 Co-processor: Intel Corporation Device 37c8
466f546c1edSFiona Trahe
467f546c1edSFiona TraheEnable the VFs for each PF by echoing the number of VFs per PF to the pci driver::
468f546c1edSFiona Trahe
469f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:1a:00.0/sriov_numvfs
470f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3d:00.0/sriov_numvfs
471f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3f:00.0/sriov_numvfs
472f546c1edSFiona Trahe
473f546c1edSFiona TraheCheck that the VFs are available for use. For example ``lspci -d:37c9`` should
474f546c1edSFiona Trahelist 48 VF devices available for a ``C62x`` device.
475f546c1edSFiona Trahe
476f546c1edSFiona TraheTo complete the installation follow the instructions in
4773cc4d996SAdam Dybkowski`Binding the available VFs to the vfio-pci driver`_.
478f546c1edSFiona Trahe
479f546c1edSFiona Trahe.. Note::
480f546c1edSFiona Trahe
481f546c1edSFiona Trahe   If the QAT kernel modules are not loaded and you see an error like ``Failed
482f546c1edSFiona Trahe   to load MMP firmware qat_895xcc_mmp.bin`` in kernel logs, this may be as a
483f546c1edSFiona Trahe   result of not using a distribution, but just updating the kernel directly.
484f546c1edSFiona Trahe
485f546c1edSFiona Trahe   Download firmware from the `kernel firmware repo
486f546c1edSFiona Trahe   <http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/>`_.
487f546c1edSFiona Trahe
488f546c1edSFiona Trahe   Copy qat binaries to ``/lib/firmware``::
489f546c1edSFiona Trahe
490f546c1edSFiona Trahe      cp qat_895xcc.bin /lib/firmware
491f546c1edSFiona Trahe      cp qat_895xcc_mmp.bin /lib/firmware
492f546c1edSFiona Trahe
493f546c1edSFiona Trahe   Change to your linux source root directory and start the qat kernel modules::
494f546c1edSFiona Trahe
495f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_common/intel_qat.ko
496f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_dh895xcc/qat_dh895xcc.ko
497f546c1edSFiona Trahe
498f546c1edSFiona Trahe.. Note::
499f546c1edSFiona Trahe
500f546c1edSFiona Trahe   If you see the following warning in ``/var/log/messages`` it can be ignored:
501f546c1edSFiona Trahe   ``IOMMU should be enabled for SR-IOV to work correctly``.
502ae20c073SDeepak Kumar Jain
5031703e94aSDeclan Doherty
50461a8759cSRebecca TroyInstallation using IDZ QAT driver
50561a8759cSRebecca Troy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5061703e94aSDeclan Doherty
50761a8759cSRebecca TroyDownload the latest QuickAssist Technology Driver from `Intel Developer Zone
50861a8759cSRebecca Troy<https://developer.intel.com/quickassist>`_.
50961a8759cSRebecca TroyConsult the *Quick Start Guide* at the same URL for further information.
5101703e94aSDeclan Doherty
5111703e94aSDeclan DohertyThe steps below assume you are:
5121703e94aSDeclan Doherty
513bb44fb6fSFiona Trahe* Building on a platform with one ``C62x`` device.
514bb44fb6fSFiona Trahe* Using package ``qat1.7.l.4.2.0-000xx.tar.gz``.
515bb44fb6fSFiona Trahe* On Fedora26 kernel ``4.11.11-300.fc26.x86_64``.
5161703e94aSDeclan Doherty
5171703e94aSDeclan DohertyIn the BIOS ensure that SRIOV is enabled and VT-d is disabled.
5181703e94aSDeclan Doherty
5191703e94aSDeclan DohertyUninstall any existing QAT driver, for example by running:
5201703e94aSDeclan Doherty
5211703e94aSDeclan Doherty* ``./installer.sh uninstall`` in the directory where originally installed.
5221703e94aSDeclan Doherty
5231703e94aSDeclan Doherty
5241703e94aSDeclan DohertyBuild and install the SRIOV-enabled QAT driver::
5251703e94aSDeclan Doherty
5261703e94aSDeclan Doherty    mkdir /QAT
5271703e94aSDeclan Doherty    cd /QAT
528f546c1edSFiona Trahe
529bb44fb6fSFiona Trahe    # Copy the package to this location and unpack
530bb44fb6fSFiona Trahe    tar zxof qat1.7.l.4.2.0-000xx.tar.gz
5311703e94aSDeclan Doherty
532bb44fb6fSFiona Trahe    ./configure --enable-icp-sriov=host
533bb44fb6fSFiona Trahe    make install
5341703e94aSDeclan Doherty
535bb44fb6fSFiona 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.
536bb44fb6fSFiona TraheYou can use ``lspci -d:37c9`` to confirm the presence of the 16 VF devices available per ``C62x`` PF.
537bb44fb6fSFiona Trahe
538bb44fb6fSFiona TraheConfirm the driver is correctly installed and is using firmware version 4.2.0::
539bb44fb6fSFiona Trahe
540bb44fb6fSFiona Trahe    cat /sys/kernel/debug/qat<your device type and bdf>/version/fw
541bb44fb6fSFiona Trahe
542bb44fb6fSFiona Trahe
543bb44fb6fSFiona TraheConfirm the presence of 48 VF devices - 16 per PF::
544bb44fb6fSFiona Trahe
545bb44fb6fSFiona Trahe    lspci -d:37c9
546bb44fb6fSFiona Trahe
5471703e94aSDeclan Doherty
5483cc4d996SAdam DybkowskiTo complete the installation - follow instructions in
5493cc4d996SAdam Dybkowski`Binding the available VFs to the vfio-pci driver`_.
5501703e94aSDeclan Doherty
551f546c1edSFiona Trahe.. Note::
552f546c1edSFiona Trahe
553f546c1edSFiona Trahe   If using a later kernel and the build fails with an error relating to
554f546c1edSFiona Trahe   ``strict_stroul`` not being available apply the following patch:
5551703e94aSDeclan Doherty
5561703e94aSDeclan Doherty   .. code-block:: diff
5571703e94aSDeclan Doherty
5581703e94aSDeclan Doherty      /QAT/QAT1.6/quickassist/utilities/downloader/Target_CoreLibs/uclo/include/linux/uclo_platform.h
5591703e94aSDeclan Doherty      + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,5)
5601703e94aSDeclan Doherty      + #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (kstrtoul((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
5611703e94aSDeclan Doherty      + #else
5621703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
5631703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (strict_strtoull((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
5641703e94aSDeclan Doherty      #else
5651703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
5661703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; strict_strtoll((str), (base), (num));}
5671703e94aSDeclan Doherty      #else
5681703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr)                                 \
5691703e94aSDeclan Doherty           do {                                                               \
5701703e94aSDeclan Doherty                 if (str[0] == '-')                                           \
5711703e94aSDeclan Doherty                 {                                                            \
5721703e94aSDeclan Doherty                      *(num) = -(simple_strtoull((str+1), &(endPtr), (base))); \
5731703e94aSDeclan Doherty                 }else {                                                      \
5741703e94aSDeclan Doherty                      *(num) = simple_strtoull((str), &(endPtr), (base));      \
5751703e94aSDeclan Doherty                 }                                                            \
5761703e94aSDeclan Doherty           } while(0)
5771703e94aSDeclan Doherty      + #endif
5781703e94aSDeclan Doherty      #endif
5791703e94aSDeclan Doherty      #endif
5801703e94aSDeclan Doherty
5811703e94aSDeclan Doherty
582f546c1edSFiona Trahe.. Note::
5831703e94aSDeclan Doherty
584f546c1edSFiona Trahe   If the build fails due to missing header files you may need to do following::
5851703e94aSDeclan Doherty
586f546c1edSFiona Trahe      sudo yum install zlib-devel
587f546c1edSFiona Trahe      sudo yum install openssl-devel
588bb44fb6fSFiona Trahe      sudo yum install libudev-devel
5891703e94aSDeclan Doherty
590f546c1edSFiona Trahe.. Note::
5911703e94aSDeclan Doherty
592f546c1edSFiona Trahe   If the build or install fails due to mismatching kernel sources you may need to do the following::
5931703e94aSDeclan Doherty
594f546c1edSFiona Trahe      sudo yum install kernel-headers-`uname -r`
595f546c1edSFiona Trahe      sudo yum install kernel-src-`uname -r`
596f546c1edSFiona Trahe      sudo yum install kernel-devel-`uname -r`
5971703e94aSDeclan Doherty
59861a8759cSRebecca Troy.. Note::
59961a8759cSRebecca Troy
60061a8759cSRebecca Troy   If the build fails on newer GCC versions (such as GCC 12) with an error relating to
60161a8759cSRebecca Troy   ``-lc`` not being found, apply the following patch:
60261a8759cSRebecca Troy
60361a8759cSRebecca Troy   .. code-block:: diff
60461a8759cSRebecca Troy
60561a8759cSRebecca Troy      /QAT/quickassist/lookaside/access_layer/src/Makefile
60661a8759cSRebecca Troy      cd $(ICP_FINAL_OUTPUT_DIR);\
60761a8759cSRebecca Troy      cmd="$(LINKER) $(LIB_SHARED_FLAGS) -o \
60861a8759cSRebecca Troy        $(LIB_SHARED) $(ADDITIONAL_OBJECTS) $(ADDITIONAL_LIBS) *.o -lpthread -ludev \
60961a8759cSRebecca Troy      - -Bstatic -L$(ADF_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL) \
61061a8759cSRebecca Troy      - -ladf_user -L$(OSAL_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL)/ \
61161a8759cSRebecca Troy      - -losal -Bdynamic -lc"; \
61261a8759cSRebecca Troy      + -Bstatic -L$(ADF_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL) \
61361a8759cSRebecca Troy      + -ladf_user -L$(OSAL_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL)/ \
61461a8759cSRebecca Troy      + -losal -Bdynamic -L/lib/x86_64-linux-gnu/ -lc"; \
61561a8759cSRebecca Troy      echo "$$cmd"; \
61661a8759cSRebecca Troy      $$cmd
61761a8759cSRebecca Troy
61861a8759cSRebecca Troy   Followed by this patch:
61961a8759cSRebecca Troy
62061a8759cSRebecca Troy   .. code-block:: diff
62161a8759cSRebecca Troy
62261a8759cSRebecca Troy      /QAT/quickassist/build_system/build_files/OS/linux_common_user_space_rules.mk
62361a8759cSRebecca Troy      @echo 'Creating shared library ${LIB_SHARED}'; \
62461a8759cSRebecca Troy      cd $($(PROG_ACY)_FINAL_OUTPUT_DIR);\
62561a8759cSRebecca Troy      -  echo $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) -lc;\
62661a8759cSRebecca Troy      -  $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) -lc ;
62761a8759cSRebecca Troy      +  echo $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) \
62861a8759cSRebecca Troy      +  -L/lib/x86_64-linux-gnu/ -lc;\
62961a8759cSRebecca Troy      +  $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) \
63061a8759cSRebecca Troy      +  -L/lib/x86_64-linux-gnu/ -lc ;
63161a8759cSRebecca Troy
632f2f639c6SDeepak Kumar Jain
6333cc4d996SAdam DybkowskiBinding the available VFs to the vfio-pci driver
63459ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6351703e94aSDeclan Doherty
6363cc4d996SAdam DybkowskiNote:
6373cc4d996SAdam Dybkowski
638b7fe612aSThomas Monjalon* Please note that due to security issues, the usage of older DPDK igb_uio
6393cc4d996SAdam Dybkowski  driver is not recommended. This document shows how to use the more secure
6403cc4d996SAdam Dybkowski  vfio-pci driver.
6413cc4d996SAdam Dybkowski* If QAT fails to bind to vfio-pci on Linux kernel 5.9+, please see the
6423cc4d996SAdam Dybkowski  QATE-39220 and QATE-7495 issues in
64361a8759cSRebecca Troy  `IDZ doc <https://cdrdv2.intel.com/v1/dl/getContent/710057?explicitVersion=true>`_
6443cc4d996SAdam Dybkowski  which details the constraint about trusted guests and add `disable_denylist=1`
6453cc4d996SAdam Dybkowski  to the vfio-pci params to use QAT. See also `this patch description <https://lkml.org/lkml/2020/7/23/1155>`_.
6463cc4d996SAdam Dybkowski
6473cc4d996SAdam DybkowskiUnbind the VFs from the stock driver so they can be bound to the vfio-pci driver.
6481703e94aSDeclan Doherty
649f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology DH895xCC device
65059ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
651f546c1edSFiona Trahe
652f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``03:01.00-03:04.07``, if your
653f546c1edSFiona TraheVFs are different adjust the unbind command below::
6541703e94aSDeclan Doherty
6553cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
6561703e94aSDeclan Doherty    for device in $(seq 1 4); do \
6571703e94aSDeclan Doherty        for fn in $(seq 0 7); do \
6583cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:03:0${device}.${fn}; \
6591703e94aSDeclan Doherty        done; \
6601703e94aSDeclan Doherty    done
6611703e94aSDeclan Doherty
662f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology C62x device
66359ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6641703e94aSDeclan Doherty
665f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``1a:01.00-1a:02.07``,
666f546c1edSFiona Trahe``3d:01.00-3d:02.07`` and ``3f:01.00-3f:02.07``, if your VFs are different
667f546c1edSFiona Traheadjust the unbind command below::
668ae20c073SDeepak Kumar Jain
6693cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
670ae20c073SDeepak Kumar Jain    for device in $(seq 1 2); do \
671ae20c073SDeepak Kumar Jain        for fn in $(seq 0 7); do \
6723cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:1a:0${device}.${fn}; \
6733cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:3d:0${device}.${fn}; \
6743cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:3f:0${device}.${fn}; \
675ae20c073SDeepak Kumar Jain        done; \
676ae20c073SDeepak Kumar Jain    done
677ae20c073SDeepak Kumar Jain
6787b08003bSAdam DybkowskiFor Intel(R) QuickAssist Technology C3xxx or 200xx or D15xx device
6797b08003bSAdam Dybkowski^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
680ae20c073SDeepak Kumar Jain
681f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``01:01.00-01:02.07``, if your
682f546c1edSFiona TraheVFs are different adjust the unbind command below::
683f2f639c6SDeepak Kumar Jain
6843cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
685f2f639c6SDeepak Kumar Jain    for device in $(seq 1 2); do \
686f2f639c6SDeepak Kumar Jain        for fn in $(seq 0 7); do \
6873cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:01:0${device}.${fn}; \
688f2f639c6SDeepak Kumar Jain        done; \
689f2f639c6SDeepak Kumar Jain    done
690f2f639c6SDeepak Kumar Jain
6913cc4d996SAdam DybkowskiBind to the vfio-pci driver
69259ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^
693f2f639c6SDeepak Kumar Jain
6943cc4d996SAdam DybkowskiLoad the vfio-pci driver, bind the VF PCI Device id to it using the
6953cc4d996SAdam Dybkowski``dpdk-devbind.py`` script then use the ``--status`` option
6963cc4d996SAdam Dybkowskito confirm the VF devices are now in use by vfio-pci kernel driver,
697f546c1edSFiona Trahee.g. for the C62x device::
698f546c1edSFiona Trahe
699f546c1edSFiona Trahe    cd to the top-level DPDK directory
7003cc4d996SAdam Dybkowski    modprobe vfio-pci
7013cc4d996SAdam Dybkowski    usertools/dpdk-devbind.py -b vfio-pci 0000:03:01.1
7023cc4d996SAdam Dybkowski    usertools/dpdk-devbind.py --status
7033cc4d996SAdam Dybkowski
7043cc4d996SAdam DybkowskiUse ``modprobe vfio-pci disable_denylist=1`` from kernel 5.9 onwards.
7053cc4d996SAdam DybkowskiSee note in the section `Binding the available VFs to the vfio-pci driver`_
7063cc4d996SAdam Dybkowskiabove.
7079333cfbaSPablo de Lara
708b1c9177bSFiona TraheTesting
709b1c9177bSFiona Trahe~~~~~~~
710b1c9177bSFiona Trahe
711bfd84d7eSArek KusztalQAT SYM crypto PMD can be tested by running the test application::
712b1c9177bSFiona Trahe
713fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
714db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
715b1c9177bSFiona Trahe    RTE>>cryptodev_qat_autotest
716b1c9177bSFiona Trahe
717bfd84d7eSArek KusztalQAT ASYM crypto PMD can be tested by running the test application::
718bfd84d7eSArek Kusztal
719fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
720db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
721bfd84d7eSArek Kusztal    RTE>>cryptodev_qat_asym_autotest
722bfd84d7eSArek Kusztal
723b1c9177bSFiona TraheQAT compression PMD can be tested by running the test application::
724b1c9177bSFiona Trahe
725fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
726db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
727b1c9177bSFiona Trahe    RTE>>compressdev_autotest
728b1c9177bSFiona Trahe
7299333cfbaSPablo de Lara
7305394c11dSFiona TraheDebugging
73159ad25feSFiona Trahe~~~~~~~~~
7325394c11dSFiona Trahe
7335394c11dSFiona TraheThere are 2 sets of trace available via the dynamic logging feature:
7345394c11dSFiona Trahe
735b1641987SThomas Monjalon* pmd.qat.dp exposes trace on the data-path.
736b1641987SThomas Monjalon* pmd.qat.general exposes all other trace.
7375394c11dSFiona Trahe
7385394c11dSFiona Trahepmd.qat exposes both sets of traces.
7395394c11dSFiona TraheThey can be enabled using the log-level option (where 8=maximum log level) on
7405394c11dSFiona Trahethe process cmdline, e.g. using any of the following::
7415394c11dSFiona Trahe
742b1641987SThomas Monjalon    --log-level="pmd.qat.general,8"
743b1641987SThomas Monjalon    --log-level="pmd.qat.dp,8"
7445394c11dSFiona Trahe    --log-level="pmd.qat,8"
7455394c11dSFiona Trahe
7465394c11dSFiona Trahe.. Note::
7475394c11dSFiona Trahe
7485394c11dSFiona Trahe    The global RTE_LOG_DP_LEVEL overrides data-path trace so must be set to
7495394c11dSFiona Trahe    RTE_LOG_DEBUG to see all the trace. This variable is in config/rte_config.h
750fd5f9fb9SCiara Power    for meson build.
7515394c11dSFiona Trahe    Also the dynamic global log level overrides both sets of trace, so e.g. no
7525394c11dSFiona Trahe    QAT trace would display in this case::
7535394c11dSFiona Trahe
754b1641987SThomas Monjalon	--log-level="7" --log-level="pmd.qat.general,8"
755