xref: /dpdk/doc/guides/cryptodevs/mlx5.rst (revision 3455ed860d66aa53c8fb8a10eabda3dc308c6500)
1a7c86884SShiri Kuzin.. SPDX-License-Identifier: BSD-3-Clause
2a7c86884SShiri Kuzin   Copyright (c) 2021 NVIDIA Corporation & Affiliates
3a7c86884SShiri Kuzin
4a7c86884SShiri Kuzin.. include:: <isonum.txt>
5a7c86884SShiri Kuzin
60f91f952SThomas MonjalonNVIDIA MLX5 Crypto Driver
70f91f952SThomas Monjalon=========================
80f91f952SThomas Monjalon
90f91f952SThomas Monjalon.. note::
100f91f952SThomas Monjalon
110f91f952SThomas Monjalon   NVIDIA acquired Mellanox Technologies in 2020.
120f91f952SThomas Monjalon   The DPDK documentation and code might still include instances
130f91f952SThomas Monjalon   of or references to Mellanox trademarks (like BlueField and ConnectX)
140f91f952SThomas Monjalon   that are now NVIDIA trademarks.
15a7c86884SShiri Kuzin
16a7c86884SShiri KuzinThe MLX5 crypto driver library
17cb0da841SRaslan Darawsheh(**librte_crypto_mlx5**) provides support for **NVIDIA ConnectX-6**,
18cb0da841SRaslan Darawsheh**NVIDIA ConnectX-6 Dx**, **NVIDIA ConnectX-7**, **NVIDIA BlueField-2**,
19cb0da841SRaslan Darawshehand **NVIDIA BlueField-3** family adapters.
20a7c86884SShiri Kuzin
21a7c86884SShiri KuzinOverview
22a7c86884SShiri Kuzin--------
23a7c86884SShiri Kuzin
246c948396SSuanming MouNVIDIA MLX5 crypto driver supports AES-XTS and AES-GCM cryption.
256c948396SSuanming Mou
266c948396SSuanming MouAES-XTS
276c948396SSuanming Mou~~~~~~~
286c948396SSuanming Mou
29a7c86884SShiri KuzinThe device can provide disk encryption services,
30a7c86884SShiri Kuzinallowing data encryption and decryption towards a disk.
31a7c86884SShiri KuzinHaving all encryption/decryption operations done in a single device
32a7c86884SShiri Kuzincan reduce cost and overheads of the related FIPS certification,
33a7c86884SShiri Kuzinas ConnectX-6 is FIPS 140-2 level-2 ready.
34a7c86884SShiri KuzinThe encryption cipher is AES-XTS of 256/512 bit key size.
35a7c86884SShiri Kuzin
36a7c86884SShiri KuzinMKEY is a memory region object in the hardware,
37a7c86884SShiri Kuzinthat holds address translation information and attributes per memory area.
38a7c86884SShiri KuzinIts ID must be tied to addresses provided to the hardware.
39a7c86884SShiri KuzinThe encryption operations are performed with MKEY read/write transactions,
40a7c86884SShiri Kuzinwhen the MKEY is configured to perform crypto operations.
41a7c86884SShiri Kuzin
42a7c86884SShiri KuzinThe encryption does not require text to be aligned to the AES block size (128b).
43a7c86884SShiri Kuzin
44a3ade5e3SMichael BaumSee :doc:`../../platform/mlx5` guide for more design details.
45247ad130SShiri Kuzin
466c948396SSuanming MouAES-GCM
476c948396SSuanming Mou~~~~~~~
486c948396SSuanming Mou
496c948396SSuanming MouThe supported AAD/digest/key size can be read from ``dev_info``.
506c948396SSuanming Mou
516c948396SSuanming MouIn AES-GCM mode, the HW requires continuous input and output of
526c948396SSuanming MouAdditional Authenticated Data (AAD), payload, and digest (if needed).
536c948396SSuanming MouHowever, the API only provides a single AAD input,
546c948396SSuanming Mouwhich means that in the out-of-place mode,
556c948396SSuanming Mouthe AAD will be used in both input and output.
566c948396SSuanming MouThis reuse of AAD in the out-of-place mode breaks the continuous output,
576c948396SSuanming Mouwhich degrades the performance and introduces extra UMR WQE.
586c948396SSuanming MouIf digest is not continuous after payload will also lead to that extra UMR WQE.
596c948396SSuanming Mou
606c948396SSuanming MouTo address this issue, the API provides ``min_mbuf_headroom_req`` and
616c948396SSuanming Mou``min_mbuf_tailroom_req`` in ``rte_cryptodev_info`` as a hint to the PMD.
626c948396SSuanming MouIt indicates the PMD can use the buffer before and after the mbuf payload
636c948396SSuanming Mouas AAD and digest space.
646c948396SSuanming MouWith this hint, the PMD will use the buffer before and after the mbuf payload
656c948396SSuanming Moudirectly via copying AAD and digest.
666c948396SSuanming MouHowever, the application must ensure that there is enough headroom and tailroom
676c948396SSuanming Moureserved for the mbuf.
686c948396SSuanming MouOr, for non-continuous operations, extra UMR WQE will be used.
696c948396SSuanming Mou
706c948396SSuanming Mou
71a3ade5e3SMichael BaumConfiguration
72a3ade5e3SMichael Baum-------------
73a7c86884SShiri Kuzin
74a3ade5e3SMichael BaumSee the :ref:`mlx5 common configuration <mlx5_common_env>`.
75a7c86884SShiri Kuzin
767b61f14eSRaslan DarawshehA device comes out of NVIDIA factory with pre-defined import methods.
776c948396SSuanming MouThere are two possible import methods: wrapped or plaintext (valid for AES-XTS only).
78f12c41bfSRaja Zidane
79f12c41bfSRaja ZidaneIn case the device is in wrapped mode, it needs to be moved to crypto operational mode.
80debb27eaSShiri KuzinIn order to move the device to crypto operational mode, credential and KEK
81debb27eaSShiri Kuzin(Key Encrypting Key) should be set as the first step.
82debb27eaSShiri KuzinThe credential will be used by the software in order to perform crypto login, and the KEK is
83debb27eaSShiri Kuzinthe AES Key Wrap Algorithm (rfc3394) key that will be used for sensitive data
84debb27eaSShiri Kuzinwrapping.
85debb27eaSShiri KuzinThe credential and the AES-XTS keys should be provided to the hardware, as ciphertext
86debb27eaSShiri Kuzinencrypted by the KEK.
87debb27eaSShiri Kuzin
88e8db4413SSuanming MouA keytag (64 bits) should be appended to the AES-XTS keys (before wrapping),
89e8db4413SSuanming Mouand will be validated when the hardware attempts to access it.
90e8db4413SSuanming Mou
91debb27eaSShiri KuzinWhen crypto engines are defined to work in wrapped import method, they come out
92debb27eaSShiri Kuzinof the factory in Commissioning mode, and thus, cannot be used for crypto operations
93debb27eaSShiri Kuzinyet. A dedicated tool is used for changing the mode from Commissioning to
94debb27eaSShiri KuzinOperational, while setting the first import_KEK and credential in plaintext.
95debb27eaSShiri KuzinThe mlxreg dedicated tool should be used as follows:
96debb27eaSShiri Kuzin
97debb27eaSShiri Kuzin- Set CRYPTO_OPERATIONAL register to set the device in crypto operational mode.
98debb27eaSShiri Kuzin
99debb27eaSShiri Kuzin  The input to this tool is:
100debb27eaSShiri Kuzin
101debb27eaSShiri Kuzin  - The first credential in plaintext, 40B.
102debb27eaSShiri Kuzin  - The first import_KEK in plaintext: kek size 0 for 16B or 1 for 32B, kek data.
103debb27eaSShiri Kuzin
104debb27eaSShiri Kuzin  Example::
105debb27eaSShiri Kuzin
106debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
107debb27eaSShiri Kuzin
108debb27eaSShiri Kuzin  The "wrapped_crypto_operational" value will be "0x00000000".
109debb27eaSShiri Kuzin  The command to set the register should be executed only once, and all the
110debb27eaSShiri Kuzin  values mentioned above should be specified in the same command.
111debb27eaSShiri Kuzin
112debb27eaSShiri Kuzin  Example::
113debb27eaSShiri Kuzin
114debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL \
115debb27eaSShiri Kuzin     --set "credential[0]=0x10000000, credential[1]=0x10000000, kek[0]=0x00000000"
116debb27eaSShiri Kuzin
117debb27eaSShiri Kuzin  All values not specified will remain 0.
118debb27eaSShiri Kuzin  "wrapped_crypto_going_to_commissioning" and  "wrapped_crypto_operational"
119debb27eaSShiri Kuzin  should not be specified.
120debb27eaSShiri Kuzin
121debb27eaSShiri Kuzin  All the device ports should set it in order to move to operational mode.
122cb0da841SRaslan Darawsheh  For BlueField-2, BlueField-3 the internal ports in the ARM system should also be set.
123debb27eaSShiri Kuzin
124debb27eaSShiri Kuzin- Query CRYPTO_OPERATIONAL register to make sure the device is in Operational
125debb27eaSShiri Kuzin  mode.
126debb27eaSShiri Kuzin
127debb27eaSShiri Kuzin  Example::
128debb27eaSShiri Kuzin
129debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
130debb27eaSShiri Kuzin
131debb27eaSShiri Kuzin  The "wrapped_crypto_operational" value will be "0x00000001" if the mode was
132debb27eaSShiri Kuzin  successfully changed to operational mode.
133debb27eaSShiri Kuzin
134f12c41bfSRaja ZidaneOn the other hand, in case of plaintext mode, there is no need for all the above,
135f12c41bfSRaja ZidaneDEK is passed in plaintext without keytag.
13640e91195SShiri Kuzin
137f12c41bfSRaja Zidane  The mlx5 crypto PMD can be verified by running the test application::
138f12c41bfSRaja Zidane    Wrapped mode:
13940e91195SShiri Kuzin      dpdk-test -c 1 -n 1 -w <dev>,class=crypto,wcs_file=<file_path>
14040e91195SShiri Kuzin      RTE>>cryptodev_mlx5_autotest
14140e91195SShiri Kuzin
142f12c41bfSRaja Zidane    Plaintext mode:
143f12c41bfSRaja Zidane      dpdk-test -c 1 -n 1 -w <dev>,class=crypto
144f12c41bfSRaja Zidane      RTE>>cryptodev_mlx5_autotest
145f12c41bfSRaja Zidane
146a7c86884SShiri Kuzin
147a7c86884SShiri KuzinDriver options
148a7c86884SShiri Kuzin--------------
149a7c86884SShiri Kuzin
150a3ade5e3SMichael BaumPlease refer to :ref:`mlx5 common options <mlx5_common_driver_options>`
151a3ade5e3SMichael Baumfor an additional list of options shared with other mlx5 drivers.
152a7c86884SShiri Kuzin
1536c948396SSuanming Mou- ``algo`` parameter [int]
1546c948396SSuanming Mou
1556c948396SSuanming Mou  - 0. AES-XTS crypto.
1566c948396SSuanming Mou
1576c948396SSuanming Mou  - 1. AES-GCM crypto.
1586c948396SSuanming Mou
1596c948396SSuanming Mou  Set to zero (AES-XTS) by default.
1606c948396SSuanming Mou
161f12c41bfSRaja Zidane- ``wcs_file`` parameter [string] - mandatory in wrapped mode
162debb27eaSShiri Kuzin
163debb27eaSShiri Kuzin  File path including only the wrapped credential in string format of hexadecimal
164debb27eaSShiri Kuzin  numbers, represent 48 bytes (8 bytes IV added by the AES key wrap algorithm).
1656c948396SSuanming Mou  This option is valid only for AES-XTS.
166debb27eaSShiri Kuzin
167debb27eaSShiri Kuzin- ``import_kek_id`` parameter [int]
168debb27eaSShiri Kuzin
169debb27eaSShiri Kuzin  The identifier of the KEK, default value is 0 represents the operational
170debb27eaSShiri Kuzin  register import_kek..
1716c948396SSuanming Mou  This option is valid only for AES-XTS.
172debb27eaSShiri Kuzin
173debb27eaSShiri Kuzin- ``credential_id`` parameter [int]
174debb27eaSShiri Kuzin
175debb27eaSShiri Kuzin  The identifier of the credential, default value is 0 represents the operational
176debb27eaSShiri Kuzin  register credential.
1776c948396SSuanming Mou  This option is valid only for AES-XTS.
178debb27eaSShiri Kuzin
179e8db4413SSuanming Mou- ``keytag`` parameter [int]
180e8db4413SSuanming Mou
1819c30a6f3SHenry Nadeau  The plaintext of the keytag appended to the AES-XTS keys, default value is 0.
1826c948396SSuanming Mou  This option is valid only for AES-XTS.
183e8db4413SSuanming Mou
184a1978aa2SSuanming Mou- ``max_segs_num`` parameter [int]
185a1978aa2SSuanming Mou
186a1978aa2SSuanming Mou  Maximum number of mbuf chain segments(src or dest), default value is 8.
187a1978aa2SSuanming Mou
1880750c8b1SSuanming Mou- ``crypto_mode`` parameter [string]
1890750c8b1SSuanming Mou
1900750c8b1SSuanming Mou  Only valid in AES-GCM mode. Will be ignored in AES-XTS mode.
1910750c8b1SSuanming Mou
1920750c8b1SSuanming Mou  - ``full_capable``
1930750c8b1SSuanming Mou    Use UMR WQE for inputs not as contiguous AAD/Payload/Digest.
1940750c8b1SSuanming Mou
1950750c8b1SSuanming Mou  - ``ipsec_opt``
1960750c8b1SSuanming Mou    Do software AAD shrink for inputs as contiguous AAD/IV/Payload/Digest.
1970750c8b1SSuanming Mou    The PMD relies on the IPsec layout, expecting the memory to align
1980750c8b1SSuanming Mou    with AAD/IV/Payload/Digest in a contiguous manner,
1990750c8b1SSuanming Mou    all within a single mbuf for any given OP.
2000750c8b1SSuanming Mou    The PMD extracts the ESP.IV bytes from the input memory
2010750c8b1SSuanming Mou    and binds the AAD (ESP SPI and SN) to the payload during enqueue OP.
2020750c8b1SSuanming Mou    It then restores the original memory layout in the decrypt OP.
2030750c8b1SSuanming Mou    The ESP.IV size supported range is [0,16] bytes.
204*3455ed86SSuanming Mou    For OOP case, the PMD will replace the bytes preceding the OP destination address
205*3455ed86SSuanming Mou    to match the information found between the AAD pointer and the OP source address.
206*3455ed86SSuanming Mou    User should prepare this headroom in this case.
2070750c8b1SSuanming Mou
2080750c8b1SSuanming Mou  Set to ``full_capable`` by default.
2090750c8b1SSuanming Mou
210a7c86884SShiri Kuzin
211a7c86884SShiri KuzinSupported NICs
212a7c86884SShiri Kuzin--------------
213a7c86884SShiri Kuzin
2147b61f14eSRaslan Darawsheh* NVIDIA\ |reg| ConnectX\ |reg|-6 200G MCX654106A-HCAT (2x200G)
2157b61f14eSRaslan Darawsheh* NVIDIA\ |reg| ConnectX\ |reg|-6 Dx
216cb0da841SRaslan Darawsheh* NVIDIA\ |reg| ConnectX\ |reg|-7
217cb0da841SRaslan Darawsheh* NVIDIA\ |reg| BlueField\ |reg|-2 SmartNIC
218cb0da841SRaslan Darawsheh* NVIDIA\ |reg| BlueField\ |reg|-3 SmartNIC
219a7c86884SShiri Kuzin
2201004be3cSShiri Kuzin
2211004be3cSShiri KuzinLimitations
2221004be3cSShiri Kuzin-----------
2231004be3cSShiri Kuzin
2241004be3cSShiri Kuzin- AES-XTS keys provided in xform must include keytag and should be wrapped.
2259ad77644SRaja Zidane- The supported data-unit lengths are 512B and 4KB and 1MB. In case the `dataunit_len`
2261004be3cSShiri Kuzin  is not provided in the cipher xform, the OP length is limited to the above
2279ad77644SRaja Zidane  values.
2286c948396SSuanming Mou- AES-GCM is supported only on BlueField-3.
2296c948396SSuanming Mou- AES-GCM supports only key import plaintext mode.
2300750c8b1SSuanming Mou- AES-GCM ``ipsec_opt`` mode does not support non-contiguous AAD/Payload/Digest
2310750c8b1SSuanming Mou  and multi-segment mode.
2321004be3cSShiri Kuzin
2331004be3cSShiri Kuzin
234a7c86884SShiri KuzinPrerequisites
235a7c86884SShiri Kuzin-------------
236a7c86884SShiri Kuzin
2374b2cc736SRaja ZidaneFW Prerequisites
2384b2cc736SRaja Zidane~~~~~~~~~~~~~~~~
2394b2cc736SRaja Zidane
2404b2cc736SRaja Zidane- xx.31.0328 for ConnectX-6.
24167e1bb42SMichael Baum- xx.32.0108 for ConnectX-6 Dx and BlueField-2.
242cb0da841SRaslan Darawsheh- xx.36.xxxx for ConnectX-7 and BlueField-3.
2436c948396SSuanming Mou- xx.37.3010 for BlueField-3 and newer for AES-GCM.
2444b2cc736SRaja Zidane
245b4a4fb7eSTal ShnaidermanLinux Prerequisites
246b4a4fb7eSTal Shnaiderman~~~~~~~~~~~~~~~~~~~
247b4a4fb7eSTal Shnaiderman
2480f91f952SThomas Monjalon- NVIDIA MLNX_OFED version: **5.3**.
249a7c86884SShiri Kuzin- Compilation can be done also with rdma-core v15+.
250a3ade5e3SMichael Baum
251a3ade5e3SMichael Baum  See :ref:`mlx5 common prerequisites <mlx5_linux_prerequisites>` for more details.
252b4a4fb7eSTal Shnaiderman
253b4a4fb7eSTal ShnaidermanWindows Prerequisites
254b4a4fb7eSTal Shnaiderman~~~~~~~~~~~~~~~~~~~~~
255b4a4fb7eSTal Shnaiderman
2560f91f952SThomas Monjalon- NVIDIA WINOF-2 version: **2.60** or higher.
257a3ade5e3SMichael Baum  See :ref:`mlx5 common prerequisites <mlx5_windows_prerequisites>` for more details.
258