xref: /dpdk/doc/guides/cryptodevs/qat.rst (revision e9271821e489668e466c7db36912b7c338717688)
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``
29f925068aSCiara Power* ``Intel QuickAssist Technology 300xx``
3059cda512SCiara Power* ``Intel QuickAssist Technology 420xx``
31*e9271821SNishikant Nayak* ``Intel QuickAssist Technology apfxx``
321703e94aSDeclan Doherty
331703e94aSDeclan Doherty
341703e94aSDeclan DohertyFeatures
3559ad25feSFiona Trahe~~~~~~~~
361703e94aSDeclan Doherty
37bfd84d7eSArek KusztalThe QAT SYM PMD has support for:
381703e94aSDeclan Doherty
391703e94aSDeclan DohertyCipher algorithms:
401703e94aSDeclan Doherty
41e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CBC``
42e1b7f509SFiona Trahe* ``RTE_CRYPTO_CIPHER_3DES_CTR``
43fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CBC``
44fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CBC``
45fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CBC``
46fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES128_CTR``
47fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES192_CTR``
48fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_AES256_CTR``
497d5ef3bbSDamian Nowak* ``RTE_CRYPTO_CIPHER_AES_XTS``
50fddf3804SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
51db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_NULL``
52d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
536cd8b4d8SArek Kusztal* ``RTE_CRYPTO_CIPHER_DES_CBC``
54d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_AES_DOCSISBPI``
55d18ab45fSFiona Trahe* ``RTE_CRYPTO_CIPHER_DES_DOCSISBPI``
56d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``
571703e94aSDeclan Doherty
581703e94aSDeclan DohertyHash algorithms:
591703e94aSDeclan Doherty
606e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA1``
611703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
626e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA224``
63ebdbe12fSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
646e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA256``
651703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
666e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA384``
67d905ee32SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
686e21c1a5SAdam Dybkowski* ``RTE_CRYPTO_AUTH_SHA512``
691703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
703a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_224``
713a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_256``
723a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_384``
733a80d7fbSCiara Power* ``RTE_CRYPTO_AUTH_SHA3_512``
741703e94aSDeclan Doherty* ``RTE_CRYPTO_AUTH_AES_XCBC_MAC``
75a38dfe97SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_SNOW3G_UIA2``
7661ec5181SArek Kusztal* ``RTE_CRYPTO_AUTH_MD5_HMAC``
77db0e952aSDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_NULL``
78d4f27453SDeepak Kumar Jain* ``RTE_CRYPTO_AUTH_KASUMI_F9``
792fa64f84SArek Kusztal* ``RTE_CRYPTO_AUTH_AES_GMAC``
80d9b7d5bbSArek Kusztal* ``RTE_CRYPTO_AUTH_ZUC_EIA3``
8191c1daa4STomasz Cel* ``RTE_CRYPTO_AUTH_AES_CMAC``
82171c655bSArkadiusz Kusztal* ``RTE_CRYPTO_AUTH_SM3``
83171c655bSArkadiusz Kusztal* ``RTE_CRYPTO_AUTH_SM3_HMAC``
841703e94aSDeclan Doherty
85b79e4c00SPablo de LaraSupported AEAD algorithms:
86655c901bSAndrea Grandi
87b79e4c00SPablo de Lara* ``RTE_CRYPTO_AEAD_AES_GCM``
887bd6f76eSTomasz Cel* ``RTE_CRYPTO_AEAD_AES_CCM``
89faa57df0SArek Kusztal* ``RTE_CRYPTO_AEAD_CHACHA20_POLY1305``
90b79e4c00SPablo de Lara
916f0ef237SDavid CoyleProtocol offloads:
926f0ef237SDavid Coyle
936f0ef237SDavid Coyle* ``RTE_SECURITY_PROTOCOL_DOCSIS``
941703e94aSDeclan Doherty
95bcd7e3e8SAdam DybkowskiSupported Chains
96bcd7e3e8SAdam Dybkowski~~~~~~~~~~~~~~~~
97bcd7e3e8SAdam Dybkowski
98bcd7e3e8SAdam DybkowskiAll the usual chains are supported and also some mixed chains:
99bcd7e3e8SAdam Dybkowski
100bcd7e3e8SAdam Dybkowski.. table:: Supported hash-cipher chains for wireless digest-encrypted cases
101bcd7e3e8SAdam Dybkowski
102bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
103bcd7e3e8SAdam Dybkowski   | Cipher algorithm | NULL AUTH | SNOW3G UIA2 | ZUC EIA3 | AES CMAC |
104bcd7e3e8SAdam Dybkowski   +==================+===========+=============+==========+==========+
105a1598e90SAdam Dybkowski   | NULL CIPHER      | Y         | 2&3         | 2&3      | Y        |
106bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
1078f393c4fSArek Kusztal   | SNOW3G UEA2      | 2&3       | 1&2&3       | 2&3      | 2&3      |
108bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
109a1598e90SAdam Dybkowski   | ZUC EEA3         | 2&3       | 2&3         | 2&3      | 2&3      |
110bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
1118f393c4fSArek Kusztal   | AES CTR          | 1&2&3     | 2&3         | 2&3      | Y        |
112bcd7e3e8SAdam Dybkowski   +------------------+-----------+-------------+----------+----------+
113bcd7e3e8SAdam Dybkowski
114bcd7e3e8SAdam Dybkowski* The combinations marked as "Y" are supported on all QAT hardware versions.
1158f393c4fSArek Kusztal* The combinations marked as "2&3" are supported on GEN2 and GEN3 QAT hardware only.
1168f393c4fSArek Kusztal* The combinations marked as "1&2&3" are supported on GEN1, GEN2 and GEN3 QAT hardware only.
117bcd7e3e8SAdam Dybkowski
118bcd7e3e8SAdam Dybkowski
1191703e94aSDeclan DohertyLimitations
12059ad25feSFiona Trahe~~~~~~~~~~~
1211703e94aSDeclan Doherty
1221703e94aSDeclan Doherty* Only supports the session-oriented API implementation (session-less APIs are not supported).
1232142e6dcSPablo de Lara* SNOW 3G (UEA2), KASUMI (F8) and ZUC (EEA3) supported only if cipher length and offset fields are byte-multiple.
1249333cfbaSPablo de Lara* SNOW 3G (UIA2) and ZUC (EIA3) supported only if hash length and offset fields are byte-multiple.
1258831895bSFiona Trahe* No BSD support as BSD QAT kernel driver not available.
126d9b7d5bbSArek Kusztal* ZUC EEA3/EIA3 is not supported by dh895xcc devices
1272a7bb4fdSFiona 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.
128026f21c0SFiona Trahe* Queue-pairs are thread-safe on Intel CPUs but Queues are not (that is, within a single
129026f21c0SFiona Trahe  queue-pair all enqueues to the TX queue must be done from one thread and all dequeues
130026f21c0SFiona Trahe  from the RX queue must be done from one thread, but enqueues and dequeues may be done
131026f21c0SFiona Trahe  in different threads.)
132aa983f03SAdam Dybkowski* A GCM limitation exists, but only in the case where there are multiple
133aa983f03SAdam Dybkowski  generations of QAT devices on a single platform.
134aa983f03SAdam Dybkowski  To optimise performance, the GCM crypto session should be initialised for the
135aa983f03SAdam Dybkowski  device generation to which the ops will be enqueued. Specifically if a GCM
136aa983f03SAdam Dybkowski  session is initialised on a GEN2 device, but then attached to an op enqueued
137aa983f03SAdam Dybkowski  to a GEN3 device, it will work but cannot take advantage of hardware
138aa983f03SAdam Dybkowski  optimisations in the GEN3 device. And if a GCM session is initialised on a
139aa983f03SAdam Dybkowski  GEN3 device, then attached to an op sent to a GEN1/GEN2 device, it will not be
140aa983f03SAdam Dybkowski  enqueued to the device and will be marked as failed. The simplest way to
141db27370bSStephen Hemminger  mitigate this is to use the PCI allowlist to avoid mixing devices of different
142aa983f03SAdam Dybkowski  generations in the same process if planning to use for GCM.
143a1598e90SAdam Dybkowski* The mixed algo feature on GEN2 is not supported by all kernel drivers. Check
144a1598e90SAdam Dybkowski  the notes under the Available Kernel Drivers table below for specific details.
1456f0ef237SDavid Coyle* Out-of-place is not supported for combined Crypto-CRC DOCSIS security
1466f0ef237SDavid Coyle  protocol.
1476f0ef237SDavid Coyle* ``RTE_CRYPTO_CIPHER_DES_DOCSISBPI`` is not supported for combined Crypto-CRC
1486f0ef237SDavid Coyle  DOCSIS security protocol.
1496b048cdfSDavid Coyle* Multi-segment buffers are not supported for combined Crypto-CRC DOCSIS
1506b048cdfSDavid Coyle  security protocol.
1511703e94aSDeclan Doherty
152bb44fb6fSFiona TraheExtra notes on KASUMI F9
15359ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
1541703e94aSDeclan Doherty
155bb44fb6fSFiona TraheWhen using KASUMI F9 authentication algorithm, the input buffer must be
156aa38c849SFiona Traheconstructed according to the
157aa38c849SFiona Trahe`3GPP KASUMI specification <http://cryptome.org/3gpp/35201-900.pdf>`_
158aa38c849SFiona Trahe(section 4.4, page 13). The input buffer has to have COUNT (4 bytes),
159aa38c849SFiona TraheFRESH (4 bytes), MESSAGE and DIRECTION (1 bit) concatenated. After the DIRECTION
160aa38c849SFiona Trahebit, a single '1' bit is appended, followed by between 0 and 7 '0' bits, so that
161aa38c849SFiona Trahethe total length of the buffer is multiple of 8 bits. Note that the actual
162aa38c849SFiona Trahemessage can be any length, specified in bits.
163bb44fb6fSFiona Trahe
164bb44fb6fSFiona TraheOnce this buffer is passed this way, when creating the crypto operation,
165aa38c849SFiona Trahelength of data to authenticate "op.sym.auth.data.length" must be the length
166bb44fb6fSFiona Traheof all the items described above, including the padding at the end.
167aa38c849SFiona TraheAlso, offset of data to authenticate "op.sym.auth.data.offset"
168bb44fb6fSFiona Trahemust be such that points at the start of the COUNT bytes.
169bb44fb6fSFiona Trahe
170f81cbc20SArek KusztalAsymmetric Crypto Service on QAT
171f81cbc20SArek Kusztal--------------------------------
172bb44fb6fSFiona Trahe
173bfd84d7eSArek KusztalThe QAT asymmetric crypto PMD (hereafter referred to as `QAT ASYM [PMD]`) provides
174bfd84d7eSArek Kusztalpoll mode crypto driver support for the following hardware accelerator devices:
175f81cbc20SArek Kusztal
176bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology DH895xCC``
177bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology C62x``
178bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology C3xxx``
179bfd84d7eSArek Kusztal* ``Intel QuickAssist Technology D15xx``
180ccb247b1SCiara Power* ``Intel QuickAssist Technology C4xxx``
181efb1a06bSArek Kusztal* ``Intel QuickAssist Technology 4xxx``
18283ce3b39SBrian Dooley* ``Intel QuickAssist Technology 401xxx``
183f925068aSCiara Power* ``Intel QuickAssist Technology 300xx``
18459cda512SCiara Power* ``Intel QuickAssist Technology 420xx``
185bfd84d7eSArek Kusztal
186bfd84d7eSArek KusztalThe QAT ASYM PMD has support for:
187bfd84d7eSArek Kusztal
188bfd84d7eSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
189bfd84d7eSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_MODINV``
1903b78aa7bSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_RSA``
191b5324d38SArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECDSA``
1926c25a68aSArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECPM``
193305e1f85SArek Kusztal* ``RTE_CRYPTO_ASYM_XFORM_ECDH``
194100c7010SArkadiusz Kusztal* ``RTE_CRYPTO_ASYM_XFORM_SM2``
195fb70b33bSArek Kusztal
196f81cbc20SArek KusztalLimitations
197f81cbc20SArek Kusztal~~~~~~~~~~~
198bb44fb6fSFiona Trahe
199bfd84d7eSArek Kusztal* Big integers longer than 4096 bits are not supported.
200026f21c0SFiona Trahe* Queue-pairs are thread-safe on Intel CPUs but Queues are not (that is, within a single
201026f21c0SFiona Trahe  queue-pair all enqueues to the TX queue must be done from one thread and all dequeues
202026f21c0SFiona Trahe  from the RX queue must be done from one thread, but enqueues and dequeues may be done
203026f21c0SFiona Trahe  in different threads.)
204e2c5f4eaSArek Kusztal* RSA-2560, RSA-3584 are not supported
205bfd84d7eSArek Kusztal
20659ad25feSFiona Trahe.. _building_qat:
20759ad25feSFiona Trahe
20859ad25feSFiona TraheBuilding PMDs on QAT
20959ad25feSFiona Trahe--------------------
210bb44fb6fSFiona Trahe
21102545b6cSFiona TraheA QAT device can host multiple acceleration services:
21202545b6cSFiona Trahe
21302545b6cSFiona Trahe* symmetric cryptography
21402545b6cSFiona Trahe* data compression
215f81cbc20SArek Kusztal* asymmetric cryptography
21602545b6cSFiona Trahe
21702545b6cSFiona TraheThese services are provided to DPDK applications via PMDs which register to
21802545b6cSFiona Traheimplement the corresponding cryptodev and compressdev APIs. The PMDs use
21902545b6cSFiona Trahecommon QAT driver code which manages the QAT PCI device. They also depend on a
22002545b6cSFiona TraheQAT kernel driver being installed on the platform, see :ref:`qat_kernel` below.
2211703e94aSDeclan Doherty
222bb44fb6fSFiona Trahe
22302545b6cSFiona TraheConfiguring and Building the DPDK QAT PMDs
22402545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22502545b6cSFiona Trahe
22602545b6cSFiona Trahe
22702545b6cSFiona TraheFurther information on configuring, building and installing DPDK is described
22843628b3dSDavid Marchand:doc:`here <../linux_gsg/build_dpdk>`.
22902545b6cSFiona Trahe
2305f40555bSTomasz Jozwiak.. _building_qat_config:
2315f40555bSTomasz Jozwiak
2327ce27b9eSFiona TraheBuild Configuration
2337ce27b9eSFiona Trahe~~~~~~~~~~~~~~~~~~~
2347ce27b9eSFiona Trahe
2357ce27b9eSFiona TraheThese are the build configuration options affecting QAT, and their default values:
2367ce27b9eSFiona Trahe
2377ce27b9eSFiona Trahe.. code-block:: console
2387ce27b9eSFiona Trahe
239fd5f9fb9SCiara Power	RTE_PMD_QAT_MAX_PCI_DEVICES=48
240fd5f9fb9SCiara Power	RTE_PMD_QAT_COMP_IM_BUFFER_SIZE=65536
2417ce27b9eSFiona Trahe
242bfd84d7eSArek KusztalBoth QAT SYM PMD and QAT ASYM PMD have an external dependency on libcrypto, so are not
243fd5f9fb9SCiara Powerbuilt by default.
2447ce27b9eSFiona Trahe
2454a39be2eSSamina ArshadUbuntu
2464a39be2eSSamina Arshad
2474a39be2eSSamina Arshad.. code-block:: console
2484a39be2eSSamina Arshad
2494a39be2eSSamina Arshad   apt install libssl-dev
2504a39be2eSSamina Arshad
2514a39be2eSSamina ArshadRHEL
2524a39be2eSSamina Arshad
2534a39be2eSSamina Arshad.. code-block:: console
2544a39be2eSSamina Arshad
2554a39be2eSSamina Arshad   dnf install openssl-devel
2564a39be2eSSamina Arshad
257fd5f9fb9SCiara PowerThe QAT compressdev PMD has no external dependencies, so is built by default.
2587ce27b9eSFiona Trahe
2597ce27b9eSFiona TraheThe number of VFs per PF varies - see table below. If multiple QAT packages are
260fd5f9fb9SCiara Powerinstalled on a platform then RTE_PMD_QAT_MAX_PCI_DEVICES should be
2617ce27b9eSFiona Traheadjusted to the number of VFs which the QAT common code will need to handle.
262bfd84d7eSArek Kusztal
263bfd84d7eSArek Kusztal.. Note::
264bfd84d7eSArek Kusztal
265bfd84d7eSArek Kusztal        There are separate config items (not QAT-specific) for max cryptodevs
266fd5f9fb9SCiara Power        RTE_CRYPTO_MAX_DEVS and max compressdevs RTE_COMPRESS_MAX_DEVS,
267bfd84d7eSArek Kusztal        if necessary these should be adjusted to handle the total of QAT and other
268bfd84d7eSArek Kusztal        devices which the process will use. In particular for crypto, where each
269bfd84d7eSArek Kusztal        QAT VF may expose two crypto devices, sym and asym, it may happen that the
270bfd84d7eSArek Kusztal        number of devices will be bigger than MAX_DEVS and the process will show an error
271fd5f9fb9SCiara Power        during PMD initialisation. To avoid this problem RTE_CRYPTO_MAX_DEVS may be
272db27370bSStephen Hemminger        increased or -a, allow domain:bus:devid:func option may be used.
273bfd84d7eSArek Kusztal
2747ce27b9eSFiona Trahe
2754e8f2d6aSFiona TraheQAT compression PMD needs intermediate buffers to support Deflate compression
276fd5f9fb9SCiara Powerwith Dynamic Huffman encoding. RTE_PMD_QAT_COMP_IM_BUFFER_SIZE
2774e8f2d6aSFiona Trahespecifies the size of a single buffer, the PMD will allocate a multiple of these,
2785f40555bSTomasz Jozwiakplus some extra space for associated meta-data. For GEN2 devices, 20 buffers are
2795f40555bSTomasz Jozwiakallocated while for GEN1 devices, 12 buffers are allocated, plus 1472 bytes overhead.
2804e8f2d6aSFiona Trahe
2814e8f2d6aSFiona Trahe.. Note::
2824e8f2d6aSFiona Trahe
2834e8f2d6aSFiona Trahe	If the compressed output of a Deflate operation using Dynamic Huffman
2844e8f2d6aSFiona Trahe	Encoding is too big to fit in an intermediate buffer, then the
285c13cecf6SAdam Dybkowski	operation will be split into smaller operations and their results will
286c13cecf6SAdam Dybkowski	be merged afterwards.
287c13cecf6SAdam Dybkowski	This is not possible if any checksum calculation was requested - in such
288c13cecf6SAdam Dybkowski	case the code falls back to fixed compression.
289a720e674STomasz Jozwiak	To avoid this less performant case, applications should configure
290a720e674STomasz Jozwiak	the intermediate buffer size to be larger than the expected input data size
291a720e674STomasz Jozwiak	(compressed output size is usually unknown, so the only option is to make
292a720e674STomasz Jozwiak	larger than the input size).
2934e8f2d6aSFiona Trahe
294bb44fb6fSFiona Trahe
295cffb726bSVikash PoddarRunning QAT PMD with insecure crypto algorithms
296cffb726bSVikash Poddar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297cffb726bSVikash Poddar
298cffb726bSVikash PoddarA few insecure crypto algorithms are deprecated from QAT drivers.
299cffb726bSVikash PoddarThis needs to be reflected in DPDK QAT PMD.
300cffb726bSVikash PoddarDPDK QAT PMD has by default disabled all the insecure crypto algorithms from Gen 1, 2, 3 and 4.
301cffb726bSVikash PoddarA PMD devarg is used to enable the capability.
302cffb726bSVikash Poddar
303cffb726bSVikash Poddar- qat_legacy_capa
304cffb726bSVikash Poddar
305cffb726bSVikash PoddarTo use this feature the user must set the devarg on process start as a device additional devarg::
306cffb726bSVikash Poddar
307cffb726bSVikash Poddar  -a b1:01.2,qat_legacy_capa=1
308cffb726bSVikash Poddar
309cffb726bSVikash Poddar
31047c3f7a4SArek KusztalRunning QAT PMD with minimum threshold for burst size
31147c3f7a4SArek Kusztal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31247c3f7a4SArek Kusztal
31347c3f7a4SArek KusztalIf only a small number or packets can be enqueued. Each enqueue causes an expensive MMIO write.
31447c3f7a4SArek KusztalThese MMIO write occurrences can be optimised by setting any of the following parameters:
31547c3f7a4SArek Kusztal
31647c3f7a4SArek Kusztal- qat_sym_enq_threshold
31747c3f7a4SArek Kusztal- qat_asym_enq_threshold
31847c3f7a4SArek Kusztal- qat_comp_enq_threshold
31947c3f7a4SArek Kusztal
32047c3f7a4SArek KusztalWhen any of these parameters is set rte_cryptodev_enqueue_burst function will
32147c3f7a4SArek Kusztalreturn 0 (thereby avoiding an MMIO) if the device is congested and number of packets
32247c3f7a4SArek Kusztalpossible to enqueue is smaller.
32347c3f7a4SArek KusztalTo use this feature the user must set the parameter on process start as a device additional parameter::
32447c3f7a4SArek Kusztal
325db27370bSStephen Hemminger  -a 03:01.1,qat_sym_enq_threshold=32,qat_comp_enq_threshold=16
32647c3f7a4SArek Kusztal
32747c3f7a4SArek KusztalAll parameters can be used with the same device regardless of order. Parameters are separated
32847c3f7a4SArek Kusztalby comma. When the same parameter is used more than once first occurrence of the parameter
32947c3f7a4SArek Kusztalis used.
33047c3f7a4SArek KusztalMaximum threshold that can be set is 32.
33147c3f7a4SArek Kusztal
332ce7a737cSKevin O'Sullivan
333ce7a737cSKevin O'SullivanRunning QAT PMD with Cipher-CRC offload feature
334ce7a737cSKevin O'Sullivan~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335ce7a737cSKevin O'Sullivan
336ce7a737cSKevin O'SullivanSupport has been added to the QAT symmetric crypto PMD for combined Cipher-CRC offload,
337ce7a737cSKevin O'Sullivanprimarily for the Crypto-CRC DOCSIS security protocol, on GEN2/GEN3/GEN4 QAT devices.
338ce7a737cSKevin O'Sullivan
339ce7a737cSKevin O'SullivanThe following devarg enables a Cipher-CRC offload capability check to determine
340ce7a737cSKevin O'Sullivanif the feature is supported on the QAT device.
341ce7a737cSKevin O'Sullivan
342ce7a737cSKevin O'Sullivan- qat_sym_cipher_crc_enable
343ce7a737cSKevin O'Sullivan
344ce7a737cSKevin O'SullivanWhen enabled, a capability check for the combined Cipher-CRC offload feature is triggered
345ce7a737cSKevin O'Sullivanto the QAT firmware during queue pair initialization. If supported by the firmware,
346ce7a737cSKevin O'Sullivanany subsequent runtime Crypto-CRC DOCSIS security protocol requests handled by the QAT PMD
347ce7a737cSKevin O'Sullivanare offloaded to the QAT device by setting up the content descriptor and request accordingly.
348ce7a737cSKevin O'SullivanIf not supported, the CRC is calculated by the QAT PMD using the NET CRC API.
349ce7a737cSKevin O'Sullivan
350ce7a737cSKevin O'SullivanTo use this feature the user must set the devarg on process start as a device additional devarg::
351ce7a737cSKevin O'Sullivan
352ce7a737cSKevin O'Sullivan -a 03:01.1,qat_sym_cipher_crc_enable=1
353ce7a737cSKevin O'Sullivan
354ce7a737cSKevin O'Sullivan
355ca0ba0e4SBrian DooleyRunning QAT PMD with Intel IPsec MB library for symmetric precomputes function
3563227bc71SKai Ji~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3573227bc71SKai Ji
358ca0ba0e4SBrian DooleyThe QAT PMD uses Intel IPsec MB library for partial hash calculation
359ca0ba0e4SBrian Dooleyin symmetric precomputes function by default,
360ca0ba0e4SBrian Dooleythe minimum required version of IPsec MB library is v1.4.
361ca0ba0e4SBrian DooleyIf this version of IPsec is not met, it will fallback to use OpenSSL.
362ca0ba0e4SBrian DooleyARM will always default to using OpenSSL
363ca0ba0e4SBrian Dooleyas ARM IPsec MB does not support the necessary algorithms.
3643227bc71SKai Ji
36547c3f7a4SArek Kusztal
366bb44fb6fSFiona TraheDevice and driver naming
36759ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
368bb44fb6fSFiona Trahe
369bfd84d7eSArek Kusztal* The qat cryptodev symmetric crypto driver name is "crypto_qat".
370bfd84d7eSArek Kusztal* The qat cryptodev asymmetric crypto driver name is "crypto_qat_asym".
371bb44fb6fSFiona Trahe
372bfd84d7eSArek KusztalThe "rte_cryptodev_devices_get()" returns the devices exposed by either of these drivers.
373bfd84d7eSArek Kusztal
374bfd84d7eSArek Kusztal* Each qat sym crypto device has a unique name, in format
375aa38c849SFiona Trahe  "<pci bdf>_<service>", e.g. "0000:41:01.0_qat_sym".
376bfd84d7eSArek Kusztal* Each qat asym crypto device has a unique name, in format
377bfd84d7eSArek Kusztal  "<pci bdf>_<service>", e.g. "0000:41:01.0_qat_asym".
378aa38c849SFiona Trahe  This name can be passed to "rte_cryptodev_get_dev_id()" to get the device_id.
379bb44fb6fSFiona Trahe
380bb44fb6fSFiona Trahe.. Note::
381bb44fb6fSFiona Trahe
382bfd84d7eSArek Kusztal	The cryptodev driver name is passed to the dpdk-test-crypto-perf tool in the "-devtype" parameter.
383bb44fb6fSFiona Trahe
38485b00824SAdam Dybkowski	The qat crypto device name is in the format of the worker parameter passed to the crypto scheduler.
385bb44fb6fSFiona Trahe
386df8cca46SFiona Trahe* The qat compressdev driver name is "compress_qat".
387bb44fb6fSFiona Trahe  The rte_compressdev_devices_get() returns the devices exposed by this driver.
388bb44fb6fSFiona Trahe
389bb44fb6fSFiona Trahe* Each qat compression device has a unique name, in format
390bb44fb6fSFiona Trahe  <pci bdf>_<service>, e.g. "0000:41:01.0_qat_comp".
391bb44fb6fSFiona Trahe  This name can be passed to rte_compressdev_get_dev_id() to get the device_id.
392bb44fb6fSFiona Trahe
39327a8c6b6SDharmik Thakkar
39427a8c6b6SDharmik ThakkarRunning QAT on Aarch64 based Ampere Altra platform
39527a8c6b6SDharmik Thakkar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39627a8c6b6SDharmik Thakkar
39727a8c6b6SDharmik ThakkarRequires Linux kernel v6.0+.
39827a8c6b6SDharmik ThakkarSee also `this kernel patch <https://lkml.org/lkml/2022/6/17/328>`_.
39927a8c6b6SDharmik Thakkar
40027a8c6b6SDharmik Thakkar
40102545b6cSFiona Trahe.. _qat_kernel:
40202545b6cSFiona Trahe
40302545b6cSFiona TraheDependency on the QAT kernel driver
40402545b6cSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40502545b6cSFiona Trahe
40602545b6cSFiona TraheTo use QAT an SRIOV-enabled QAT kernel driver is required. The VF
40702545b6cSFiona Trahedevices created and initialised by this driver will be used by the QAT PMDs.
40802545b6cSFiona Trahe
40902545b6cSFiona TraheInstructions for installation are below, but first an explanation of the
41002545b6cSFiona Traherelationships between the PF/VF devices and the PMDs visible to
41102545b6cSFiona TraheDPDK applications.
41202545b6cSFiona Trahe
41302545b6cSFiona TraheEach QuickAssist PF device exposes a number of VF devices. Each VF device can
414bfd84d7eSArek Kusztalenable one symmetric cryptodev PMD and/or one asymmetric cryptodev PMD and/or
415bfd84d7eSArek Kusztalone compressdev PMD.
41602545b6cSFiona TraheThese QAT PMDs share the same underlying device and pci-mgmt code, but are
41702545b6cSFiona Traheenumerated independently on their respective APIs and appear as independent
41802545b6cSFiona Trahedevices to applications.
41902545b6cSFiona Trahe
42002545b6cSFiona Trahe.. Note::
42102545b6cSFiona Trahe
42202545b6cSFiona Trahe   Each VF can only be used by one DPDK process. It is not possible to share
42302545b6cSFiona Trahe   the same VF across multiple processes, even if these processes are using
42402545b6cSFiona Trahe   different acceleration services.
42502545b6cSFiona Trahe
42602545b6cSFiona Trahe   Conversely one DPDK process can use one or more QAT VFs and can expose both
42702545b6cSFiona Trahe   cryptodev and compressdev instances on each of those VFs.
42802545b6cSFiona Trahe
429bb44fb6fSFiona Trahe
430bb44fb6fSFiona TraheAvailable kernel drivers
43159ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~
432bb44fb6fSFiona Trahe
433ab3dec55SFiona TraheKernel drivers for each device for each service are listed in the following table. (Scroll right
434ab3dec55SFiona Traheto see the full table)
435bb44fb6fSFiona Trahe
4361703e94aSDeclan Doherty
437f546c1edSFiona Trahe.. _table_qat_pmds_drivers:
438f546c1edSFiona Trahe
439f5160653SArek Kusztal.. table:: QAT device generations, devices and drivers
440f546c1edSFiona Trahe
441ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
442ab3dec55SFiona Trahe   | S   | A   | C   | Gen | Device   | Driver/ver    | Kernel Module | Pci Driver | PF Did | #PFs | VF Did | VFs/PF |
443ab3dec55SFiona Trahe   +=====+=====+=====+=====+==========+===============+===============+============+========+======+========+========+
444ab3dec55SFiona Trahe   | Yes | No  | No  | 1   | DH895xCC | linux/4.4+    | qat_dh895xcc  | dh895xcc   | 435    | 1    | 443    | 32     |
445ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
44661a8759cSRebecca Troy   | Yes | Yes | No  | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
447ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
44861a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.13.0+   | "             | "          | "      | "    | "      | "      |
449ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
450ab3dec55SFiona Trahe   | Yes | No  | No  | 2   | C62x     | linux/4.5+    | qat_c62x      | c6xx       | 37c8   | 3    | 37c9   | 16     |
451ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
45261a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
453ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
454ab3dec55SFiona Trahe   | Yes | No  | No  | 2   | C3xxx    | linux/4.5+    | qat_c3xxx     | c3xxx      | 19e2   | 1    | 19e3   | 16     |
455ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
45661a8759cSRebecca Troy   | Yes | Yes | Yes | "   | "        | IDZ/4.12.0+   | "             | "          | "      | "    | "      | "      |
457ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
4587b08003bSAdam Dybkowski   | Yes | No  | No  | 2   | 200xx    | p             | qat_200xx     | 200xx      | 18ee   | 1    | 18ef   | 16     |
4597b08003bSAdam Dybkowski   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
46061a8759cSRebecca Troy   | Yes | No  | No  | 2   | D15xx    | p             | qat_d15xx     | d15xx      | 6f54   | 1    | 6f55   | 16     |
461ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
462ccb247b1SCiara Power   | Yes | Yes | No  | 3   | C4xxx    | p             | qat_c4xxx     | c4xxx      | 18a0   | 1    | 18a1   | 128    |
463ab3dec55SFiona Trahe   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
46483ce3b39SBrian Dooley   | Yes | Yes | No  | 4   | 4xxx     | linux/5.11+   | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
4658f393c4fSArek Kusztal   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
46683ce3b39SBrian Dooley   | Yes | Yes | Yes | 4   | 4xxx     | linux/5.17+   | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
46783ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
46883ce3b39SBrian Dooley   | Yes | No  | No  | 4   | 4xxx     | IDZ/ N/A      | qat_4xxx      | 4xxx       | 4940   | 4    | 4941   | 16     |
46983ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
470188ace04SBrian Dooley   | Yes | Yes | Yes | 4   | 401xxx   | linux/5.19+   | qat_4xxx      | 4xxx       | 4942   | 2    | 4943   | 16     |
47183ce3b39SBrian Dooley   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
472188ace04SBrian Dooley   | Yes | No  | No  | 4   | 401xxx   | IDZ/ N/A      | qat_4xxx      | 4xxx       | 4942   | 2    | 4943   | 16     |
473f4eac3a0SArek Kusztal   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
4744728d843SCiara Power   | Yes | Yes | Yes | 4   | 402xx    | linux/6.4+    | qat_4xxx      | 4xxx       | 4944   | 2    | 4945   | 16     |
4754728d843SCiara Power   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
4764728d843SCiara Power   | Yes | No  | No  | 4   | 402xx    | IDZ/ N/A      | qat_4xxx      | 4xxx       | 4944   | 2    | 4945   | 16     |
4774728d843SCiara Power   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
47859cda512SCiara Power   | Yes | Yes | Yes | 5   | 420xx    | linux/6.8+    | qat_420xx     | 420xx      | 4946   | 2    | 4947   | 16     |
47959cda512SCiara Power   +-----+-----+-----+-----+----------+---------------+---------------+------------+--------+------+--------+--------+
480f546c1edSFiona Trahe
48161a8759cSRebecca Troy* Note: Symmetric mixed crypto algorithms feature on Gen 2 works only with IDZ driver version 4.9.0+
482a1598e90SAdam Dybkowski
483ab3dec55SFiona TraheThe first 3 columns indicate the service:
484ab3dec55SFiona Trahe
485ab3dec55SFiona Trahe* S = Symmetric crypto service (via cryptodev API)
486ab3dec55SFiona Trahe* A = Asymmetric crypto service  (via cryptodev API)
487ab3dec55SFiona Trahe* C = Compression service (via compressdev API)
488f546c1edSFiona Trahe
489f546c1edSFiona TraheThe ``Driver`` column indicates either the Linux kernel version in which
49061a8759cSRebecca Troysupport for this device was introduced or a driver available on Intel Developer Zone (IDZ).
49161a8759cSRebecca TroyThere are both linux in-tree and IDZ kernel drivers available for some
492259310f3SFiona Trahedevices. p = release pending.
493f546c1edSFiona Trahe
494f546c1edSFiona TraheIf you are running on a kernel which includes a driver for your device, see
495f546c1edSFiona Trahe`Installation using kernel.org driver`_ below. Otherwise see
49661a8759cSRebecca Troy`Installation using IDZ QAT driver`_.
497f546c1edSFiona Trahe
49883ce3b39SBrian Dooley.. note::
49983ce3b39SBrian Dooley
50083ce3b39SBrian Dooley   The asymmetric service is not supported by DPDK QAT PMD for the Gen 3 platform.
50183ce3b39SBrian Dooley   The actual crypto services enabled on the system depend
50283ce3b39SBrian Dooley   on QAT driver capabilities and hardware slice configuration.
503f546c1edSFiona Trahe
504f546c1edSFiona TraheInstallation using kernel.org driver
50559ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
506f546c1edSFiona Trahe
507f546c1edSFiona TraheThe examples below are based on the C62x device, if you have a different device
508f546c1edSFiona Traheuse the corresponding values in the above table.
509f546c1edSFiona Trahe
510f546c1edSFiona TraheIn BIOS ensure that SRIOV is enabled and either:
511f546c1edSFiona Trahe
512f546c1edSFiona Trahe* Disable VT-d or
513f546c1edSFiona Trahe* Enable VT-d and set ``"intel_iommu=on iommu=pt"`` in the grub file.
514f546c1edSFiona Trahe
515f546c1edSFiona TraheCheck that the QAT driver is loaded on your system, by executing::
516f546c1edSFiona Trahe
517f546c1edSFiona Trahe    lsmod | grep qa
518f546c1edSFiona Trahe
519f546c1edSFiona TraheYou should see the kernel module for your device listed, e.g.::
520f546c1edSFiona Trahe
521f546c1edSFiona Trahe    qat_c62x               5626  0
522f546c1edSFiona Trahe    intel_qat              82336  1 qat_c62x
523f546c1edSFiona Trahe
524f546c1edSFiona TraheNext, you need to expose the Virtual Functions (VFs) using the sysfs file system.
525f546c1edSFiona Trahe
526f546c1edSFiona TraheFirst find the BDFs (Bus-Device-Function) of the physical functions (PFs) of
527f546c1edSFiona Traheyour device, e.g.::
528f546c1edSFiona Trahe
529f546c1edSFiona Trahe    lspci -d:37c8
530f546c1edSFiona Trahe
531f546c1edSFiona TraheYou should see output similar to::
532f546c1edSFiona Trahe
533f546c1edSFiona Trahe    1a:00.0 Co-processor: Intel Corporation Device 37c8
534f546c1edSFiona Trahe    3d:00.0 Co-processor: Intel Corporation Device 37c8
535f546c1edSFiona Trahe    3f:00.0 Co-processor: Intel Corporation Device 37c8
536f546c1edSFiona Trahe
537f546c1edSFiona TraheEnable the VFs for each PF by echoing the number of VFs per PF to the pci driver::
538f546c1edSFiona Trahe
539f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:1a:00.0/sriov_numvfs
540f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3d:00.0/sriov_numvfs
541f546c1edSFiona Trahe     echo 16 > /sys/bus/pci/drivers/c6xx/0000:3f:00.0/sriov_numvfs
542f546c1edSFiona Trahe
543f546c1edSFiona TraheCheck that the VFs are available for use. For example ``lspci -d:37c9`` should
544f546c1edSFiona Trahelist 48 VF devices available for a ``C62x`` device.
545f546c1edSFiona Trahe
546f546c1edSFiona TraheTo complete the installation follow the instructions in
5473cc4d996SAdam Dybkowski`Binding the available VFs to the vfio-pci driver`_.
548f546c1edSFiona Trahe
549f546c1edSFiona Trahe.. Note::
550f546c1edSFiona Trahe
551f546c1edSFiona Trahe   If the QAT kernel modules are not loaded and you see an error like ``Failed
552f546c1edSFiona Trahe   to load MMP firmware qat_895xcc_mmp.bin`` in kernel logs, this may be as a
553f546c1edSFiona Trahe   result of not using a distribution, but just updating the kernel directly.
554f546c1edSFiona Trahe
555f546c1edSFiona Trahe   Download firmware from the `kernel firmware repo
556f546c1edSFiona Trahe   <http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/>`_.
557f546c1edSFiona Trahe
558f546c1edSFiona Trahe   Copy qat binaries to ``/lib/firmware``::
559f546c1edSFiona Trahe
560f546c1edSFiona Trahe      cp qat_895xcc.bin /lib/firmware
561f546c1edSFiona Trahe      cp qat_895xcc_mmp.bin /lib/firmware
562f546c1edSFiona Trahe
563f546c1edSFiona Trahe   Change to your linux source root directory and start the qat kernel modules::
564f546c1edSFiona Trahe
565f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_common/intel_qat.ko
566f546c1edSFiona Trahe      insmod ./drivers/crypto/qat/qat_dh895xcc/qat_dh895xcc.ko
567f546c1edSFiona Trahe
568f546c1edSFiona Trahe.. Note::
569f546c1edSFiona Trahe
570f546c1edSFiona Trahe   If you see the following warning in ``/var/log/messages`` it can be ignored:
571f546c1edSFiona Trahe   ``IOMMU should be enabled for SR-IOV to work correctly``.
572ae20c073SDeepak Kumar Jain
5731703e94aSDeclan Doherty
57461a8759cSRebecca TroyInstallation using IDZ QAT driver
57561a8759cSRebecca Troy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5761703e94aSDeclan Doherty
57761a8759cSRebecca TroyDownload the latest QuickAssist Technology Driver from `Intel Developer Zone
57861a8759cSRebecca Troy<https://developer.intel.com/quickassist>`_.
57961a8759cSRebecca TroyConsult the *Quick Start Guide* at the same URL for further information.
5801703e94aSDeclan Doherty
5811703e94aSDeclan DohertyThe steps below assume you are:
5821703e94aSDeclan Doherty
583bb44fb6fSFiona Trahe* Building on a platform with one ``C62x`` device.
584bb44fb6fSFiona Trahe* Using package ``qat1.7.l.4.2.0-000xx.tar.gz``.
585bb44fb6fSFiona Trahe* On Fedora26 kernel ``4.11.11-300.fc26.x86_64``.
5861703e94aSDeclan Doherty
5871703e94aSDeclan DohertyIn the BIOS ensure that SRIOV is enabled and VT-d is disabled.
5881703e94aSDeclan Doherty
5891703e94aSDeclan DohertyUninstall any existing QAT driver, for example by running:
5901703e94aSDeclan Doherty
5911703e94aSDeclan Doherty* ``./installer.sh uninstall`` in the directory where originally installed.
5921703e94aSDeclan Doherty
5931703e94aSDeclan Doherty
5941703e94aSDeclan DohertyBuild and install the SRIOV-enabled QAT driver::
5951703e94aSDeclan Doherty
5961703e94aSDeclan Doherty    mkdir /QAT
5971703e94aSDeclan Doherty    cd /QAT
598f546c1edSFiona Trahe
599bb44fb6fSFiona Trahe    # Copy the package to this location and unpack
600bb44fb6fSFiona Trahe    tar zxof qat1.7.l.4.2.0-000xx.tar.gz
6011703e94aSDeclan Doherty
602bb44fb6fSFiona Trahe    ./configure --enable-icp-sriov=host
603bb44fb6fSFiona Trahe    make install
6041703e94aSDeclan Doherty
605bb44fb6fSFiona 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.
606bb44fb6fSFiona TraheYou can use ``lspci -d:37c9`` to confirm the presence of the 16 VF devices available per ``C62x`` PF.
607bb44fb6fSFiona Trahe
608bb44fb6fSFiona TraheConfirm the driver is correctly installed and is using firmware version 4.2.0::
609bb44fb6fSFiona Trahe
610bb44fb6fSFiona Trahe    cat /sys/kernel/debug/qat<your device type and bdf>/version/fw
611bb44fb6fSFiona Trahe
612bb44fb6fSFiona Trahe
613bb44fb6fSFiona TraheConfirm the presence of 48 VF devices - 16 per PF::
614bb44fb6fSFiona Trahe
615bb44fb6fSFiona Trahe    lspci -d:37c9
616bb44fb6fSFiona Trahe
6171703e94aSDeclan Doherty
6183cc4d996SAdam DybkowskiTo complete the installation - follow instructions in
6193cc4d996SAdam Dybkowski`Binding the available VFs to the vfio-pci driver`_.
6201703e94aSDeclan Doherty
621f546c1edSFiona Trahe.. Note::
622f546c1edSFiona Trahe
623f546c1edSFiona Trahe   If using a later kernel and the build fails with an error relating to
624f546c1edSFiona Trahe   ``strict_stroul`` not being available apply the following patch:
6251703e94aSDeclan Doherty
6261703e94aSDeclan Doherty   .. code-block:: diff
6271703e94aSDeclan Doherty
6281703e94aSDeclan Doherty      /QAT/QAT1.6/quickassist/utilities/downloader/Target_CoreLibs/uclo/include/linux/uclo_platform.h
6291703e94aSDeclan Doherty      + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,5)
6301703e94aSDeclan Doherty      + #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (kstrtoul((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
6311703e94aSDeclan Doherty      + #else
6321703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
6331703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; if (strict_strtoull((str), (base), (num))) printk("Error strtoull convert %s\n", str); }
6341703e94aSDeclan Doherty      #else
6351703e94aSDeclan Doherty      #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
6361703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr) {endPtr=NULL; strict_strtoll((str), (base), (num));}
6371703e94aSDeclan Doherty      #else
6381703e94aSDeclan Doherty      #define STR_TO_64(str, base, num, endPtr)                                 \
6391703e94aSDeclan Doherty           do {                                                               \
6401703e94aSDeclan Doherty                 if (str[0] == '-')                                           \
6411703e94aSDeclan Doherty                 {                                                            \
6421703e94aSDeclan Doherty                      *(num) = -(simple_strtoull((str+1), &(endPtr), (base))); \
6431703e94aSDeclan Doherty                 }else {                                                      \
6441703e94aSDeclan Doherty                      *(num) = simple_strtoull((str), &(endPtr), (base));      \
6451703e94aSDeclan Doherty                 }                                                            \
6461703e94aSDeclan Doherty           } while(0)
6471703e94aSDeclan Doherty      + #endif
6481703e94aSDeclan Doherty      #endif
6491703e94aSDeclan Doherty      #endif
6501703e94aSDeclan Doherty
6511703e94aSDeclan Doherty
652f546c1edSFiona Trahe.. Note::
6531703e94aSDeclan Doherty
654f546c1edSFiona Trahe   If the build fails due to missing header files you may need to do following::
6551703e94aSDeclan Doherty
656f546c1edSFiona Trahe      sudo yum install zlib-devel
657f546c1edSFiona Trahe      sudo yum install openssl-devel
658bb44fb6fSFiona Trahe      sudo yum install libudev-devel
6591703e94aSDeclan Doherty
660f546c1edSFiona Trahe.. Note::
6611703e94aSDeclan Doherty
662f546c1edSFiona Trahe   If the build or install fails due to mismatching kernel sources you may need to do the following::
6631703e94aSDeclan Doherty
664f546c1edSFiona Trahe      sudo yum install kernel-headers-`uname -r`
665f546c1edSFiona Trahe      sudo yum install kernel-src-`uname -r`
666f546c1edSFiona Trahe      sudo yum install kernel-devel-`uname -r`
6671703e94aSDeclan Doherty
66861a8759cSRebecca Troy.. Note::
66961a8759cSRebecca Troy
67061a8759cSRebecca Troy   If the build fails on newer GCC versions (such as GCC 12) with an error relating to
67161a8759cSRebecca Troy   ``-lc`` not being found, apply the following patch:
67261a8759cSRebecca Troy
67361a8759cSRebecca Troy   .. code-block:: diff
67461a8759cSRebecca Troy
67561a8759cSRebecca Troy      /QAT/quickassist/lookaside/access_layer/src/Makefile
67661a8759cSRebecca Troy      cd $(ICP_FINAL_OUTPUT_DIR);\
67761a8759cSRebecca Troy      cmd="$(LINKER) $(LIB_SHARED_FLAGS) -o \
67861a8759cSRebecca Troy        $(LIB_SHARED) $(ADDITIONAL_OBJECTS) $(ADDITIONAL_LIBS) *.o -lpthread -ludev \
67961a8759cSRebecca Troy      - -Bstatic -L$(ADF_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL) \
68061a8759cSRebecca Troy      - -ladf_user -L$(OSAL_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL)/ \
68161a8759cSRebecca Troy      - -losal -Bdynamic -lc"; \
68261a8759cSRebecca Troy      + -Bstatic -L$(ADF_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL) \
68361a8759cSRebecca Troy      + -ladf_user -L$(OSAL_DIR)/src/build/$(ICP_OS)/$(ICP_OS_LEVEL)/ \
68461a8759cSRebecca Troy      + -losal -Bdynamic -L/lib/x86_64-linux-gnu/ -lc"; \
68561a8759cSRebecca Troy      echo "$$cmd"; \
68661a8759cSRebecca Troy      $$cmd
68761a8759cSRebecca Troy
68861a8759cSRebecca Troy   Followed by this patch:
68961a8759cSRebecca Troy
69061a8759cSRebecca Troy   .. code-block:: diff
69161a8759cSRebecca Troy
69261a8759cSRebecca Troy      /QAT/quickassist/build_system/build_files/OS/linux_common_user_space_rules.mk
69361a8759cSRebecca Troy      @echo 'Creating shared library ${LIB_SHARED}'; \
69461a8759cSRebecca Troy      cd $($(PROG_ACY)_FINAL_OUTPUT_DIR);\
69561a8759cSRebecca Troy      -  echo $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) -lc;\
69661a8759cSRebecca Troy      -  $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) -lc ;
69761a8759cSRebecca Troy      +  echo $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) \
69861a8759cSRebecca Troy      +  -L/lib/x86_64-linux-gnu/ -lc;\
69961a8759cSRebecca Troy      +  $(LINKER) $(LIB_SHARED_FLAGS) -o $@  $(OBJECTS) $(ADDITIONAL_OBJECTS) \
70061a8759cSRebecca Troy      +  -L/lib/x86_64-linux-gnu/ -lc ;
70161a8759cSRebecca Troy
702f2f639c6SDeepak Kumar Jain
7033cc4d996SAdam DybkowskiBinding the available VFs to the vfio-pci driver
70459ad25feSFiona Trahe~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7051703e94aSDeclan Doherty
7063cc4d996SAdam DybkowskiNote:
7073cc4d996SAdam Dybkowski
708b7fe612aSThomas Monjalon* Please note that due to security issues, the usage of older DPDK igb_uio
7093cc4d996SAdam Dybkowski  driver is not recommended. This document shows how to use the more secure
7103cc4d996SAdam Dybkowski  vfio-pci driver.
7113cc4d996SAdam Dybkowski* If QAT fails to bind to vfio-pci on Linux kernel 5.9+, please see the
7123cc4d996SAdam Dybkowski  QATE-39220 and QATE-7495 issues in
71361a8759cSRebecca Troy  `IDZ doc <https://cdrdv2.intel.com/v1/dl/getContent/710057?explicitVersion=true>`_
7143cc4d996SAdam Dybkowski  which details the constraint about trusted guests and add `disable_denylist=1`
7153cc4d996SAdam Dybkowski  to the vfio-pci params to use QAT. See also `this patch description <https://lkml.org/lkml/2020/7/23/1155>`_.
7163cc4d996SAdam Dybkowski
7173cc4d996SAdam DybkowskiUnbind the VFs from the stock driver so they can be bound to the vfio-pci driver.
7181703e94aSDeclan Doherty
719f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology DH895xCC device
72059ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
721f546c1edSFiona Trahe
722f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``03:01.00-03:04.07``, if your
723f546c1edSFiona TraheVFs are different adjust the unbind command below::
7241703e94aSDeclan Doherty
7253cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
7261703e94aSDeclan Doherty    for device in $(seq 1 4); do \
7271703e94aSDeclan Doherty        for fn in $(seq 0 7); do \
7283cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:03:0${device}.${fn}; \
7291703e94aSDeclan Doherty        done; \
7301703e94aSDeclan Doherty    done
7311703e94aSDeclan Doherty
732f546c1edSFiona TraheFor an Intel(R) QuickAssist Technology C62x device
73359ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7341703e94aSDeclan Doherty
735f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``1a:01.00-1a:02.07``,
736f546c1edSFiona Trahe``3d:01.00-3d:02.07`` and ``3f:01.00-3f:02.07``, if your VFs are different
737f546c1edSFiona Traheadjust the unbind command below::
738ae20c073SDeepak Kumar Jain
7393cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
740ae20c073SDeepak Kumar Jain    for device in $(seq 1 2); do \
741ae20c073SDeepak Kumar Jain        for fn in $(seq 0 7); do \
7423cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:1a:0${device}.${fn}; \
7433cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:3d:0${device}.${fn}; \
7443cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:3f:0${device}.${fn}; \
745ae20c073SDeepak Kumar Jain        done; \
746ae20c073SDeepak Kumar Jain    done
747ae20c073SDeepak Kumar Jain
7487b08003bSAdam DybkowskiFor Intel(R) QuickAssist Technology C3xxx or 200xx or D15xx device
7497b08003bSAdam Dybkowski^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
750ae20c073SDeepak Kumar Jain
751f546c1edSFiona TraheThe unbind command below assumes ``BDFs`` of ``01:01.00-01:02.07``, if your
752f546c1edSFiona TraheVFs are different adjust the unbind command below::
753f2f639c6SDeepak Kumar Jain
7543cc4d996SAdam Dybkowski    cd to the top-level DPDK directory
755f2f639c6SDeepak Kumar Jain    for device in $(seq 1 2); do \
756f2f639c6SDeepak Kumar Jain        for fn in $(seq 0 7); do \
7573cc4d996SAdam Dybkowski            usertools/dpdk-devbind.py -u 0000:01:0${device}.${fn}; \
758f2f639c6SDeepak Kumar Jain        done; \
759f2f639c6SDeepak Kumar Jain    done
760f2f639c6SDeepak Kumar Jain
7613cc4d996SAdam DybkowskiBind to the vfio-pci driver
76259ad25feSFiona Trahe^^^^^^^^^^^^^^^^^^^^^^^^^^^
763f2f639c6SDeepak Kumar Jain
7643cc4d996SAdam DybkowskiLoad the vfio-pci driver, bind the VF PCI Device id to it using the
7653cc4d996SAdam Dybkowski``dpdk-devbind.py`` script then use the ``--status`` option
7663cc4d996SAdam Dybkowskito confirm the VF devices are now in use by vfio-pci kernel driver,
767f546c1edSFiona Trahee.g. for the C62x device::
768f546c1edSFiona Trahe
769f546c1edSFiona Trahe    cd to the top-level DPDK directory
7703cc4d996SAdam Dybkowski    modprobe vfio-pci
7713cc4d996SAdam Dybkowski    usertools/dpdk-devbind.py -b vfio-pci 0000:03:01.1
7723cc4d996SAdam Dybkowski    usertools/dpdk-devbind.py --status
7733cc4d996SAdam Dybkowski
7743cc4d996SAdam DybkowskiUse ``modprobe vfio-pci disable_denylist=1`` from kernel 5.9 onwards.
7753cc4d996SAdam DybkowskiSee note in the section `Binding the available VFs to the vfio-pci driver`_
7763cc4d996SAdam Dybkowskiabove.
7779333cfbaSPablo de Lara
778b1c9177bSFiona TraheTesting
779b1c9177bSFiona Trahe~~~~~~~
780b1c9177bSFiona Trahe
781bfd84d7eSArek KusztalQAT SYM crypto PMD can be tested by running the test application::
782b1c9177bSFiona Trahe
783fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
784db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
785b1c9177bSFiona Trahe    RTE>>cryptodev_qat_autotest
786b1c9177bSFiona Trahe
787bfd84d7eSArek KusztalQAT ASYM crypto PMD can be tested by running the test application::
788bfd84d7eSArek Kusztal
789fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
790db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
791bfd84d7eSArek Kusztal    RTE>>cryptodev_qat_asym_autotest
792bfd84d7eSArek Kusztal
793b1c9177bSFiona TraheQAT compression PMD can be tested by running the test application::
794b1c9177bSFiona Trahe
795fd5f9fb9SCiara Power    cd ./<build_dir>/app/test
796db27370bSStephen Hemminger    ./dpdk-test -l1 -n1 -a <your qat bdf>
797b1c9177bSFiona Trahe    RTE>>compressdev_autotest
798b1c9177bSFiona Trahe
7999333cfbaSPablo de Lara
8005394c11dSFiona TraheDebugging
80159ad25feSFiona Trahe~~~~~~~~~
8025394c11dSFiona Trahe
8035394c11dSFiona TraheThere are 2 sets of trace available via the dynamic logging feature:
8045394c11dSFiona Trahe
805b1641987SThomas Monjalon* pmd.qat.dp exposes trace on the data-path.
806b1641987SThomas Monjalon* pmd.qat.general exposes all other trace.
8075394c11dSFiona Trahe
8085394c11dSFiona Trahepmd.qat exposes both sets of traces.
8095394c11dSFiona TraheThey can be enabled using the log-level option (where 8=maximum log level) on
8105394c11dSFiona Trahethe process cmdline, e.g. using any of the following::
8115394c11dSFiona Trahe
812b1641987SThomas Monjalon    --log-level="pmd.qat.general,8"
813b1641987SThomas Monjalon    --log-level="pmd.qat.dp,8"
8145394c11dSFiona Trahe    --log-level="pmd.qat,8"
8155394c11dSFiona Trahe
8165394c11dSFiona Trahe.. Note::
8175394c11dSFiona Trahe
8185394c11dSFiona Trahe    The global RTE_LOG_DP_LEVEL overrides data-path trace so must be set to
8195394c11dSFiona Trahe    RTE_LOG_DEBUG to see all the trace. This variable is in config/rte_config.h
820fd5f9fb9SCiara Power    for meson build.
8215394c11dSFiona Trahe    Also the dynamic global log level overrides both sets of trace, so e.g. no
8225394c11dSFiona Trahe    QAT trace would display in this case::
8235394c11dSFiona Trahe
824b1641987SThomas Monjalon	--log-level="7" --log-level="pmd.qat.general,8"
825