xref: /dpdk/doc/guides/cryptodevs/mlx5.rst (revision a1978aa23bf4a8dd34087173f7769250d050315e)
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
6a7c86884SShiri KuzinMLX5 Crypto Driver
7a7c86884SShiri Kuzin==================
8a7c86884SShiri Kuzin
9a7c86884SShiri KuzinThe MLX5 crypto driver library
10a7c86884SShiri Kuzin(**librte_crypto_mlx5**) provides support for **Mellanox ConnectX-6**
11a7c86884SShiri Kuzinfamily adapters.
12a7c86884SShiri Kuzin
13a7c86884SShiri KuzinOverview
14a7c86884SShiri Kuzin--------
15a7c86884SShiri Kuzin
16a7c86884SShiri KuzinThe device can provide disk encryption services,
17a7c86884SShiri Kuzinallowing data encryption and decryption towards a disk.
18a7c86884SShiri KuzinHaving all encryption/decryption operations done in a single device
19a7c86884SShiri Kuzincan reduce cost and overheads of the related FIPS certification,
20a7c86884SShiri Kuzinas ConnectX-6 is FIPS 140-2 level-2 ready.
21a7c86884SShiri KuzinThe encryption cipher is AES-XTS of 256/512 bit key size.
22a7c86884SShiri Kuzin
23a7c86884SShiri KuzinMKEY is a memory region object in the hardware,
24a7c86884SShiri Kuzinthat holds address translation information and attributes per memory area.
25a7c86884SShiri KuzinIts ID must be tied to addresses provided to the hardware.
26a7c86884SShiri KuzinThe encryption operations are performed with MKEY read/write transactions,
27a7c86884SShiri Kuzinwhen the MKEY is configured to perform crypto operations.
28a7c86884SShiri Kuzin
29a7c86884SShiri KuzinThe encryption does not require text to be aligned to the AES block size (128b).
30a7c86884SShiri Kuzin
31247ad130SShiri KuzinFor security reasons and to increase robustness, this driver only deals with virtual
32247ad130SShiri Kuzinmemory addresses. The way resources allocations are handled by the kernel,
33247ad130SShiri Kuzincombined with hardware specifications that allow handling virtual memory
34247ad130SShiri Kuzinaddresses directly, ensure that DPDK applications cannot access random
35247ad130SShiri Kuzinphysical memory (or memory that does not belong to the current process).
36247ad130SShiri Kuzin
37a7c86884SShiri KuzinThe PMD uses ``libibverbs`` and ``libmlx5`` to access the device firmware
38a7c86884SShiri Kuzinor to access the hardware components directly.
39a7c86884SShiri KuzinThere are different levels of objects and bypassing abilities.
40a7c86884SShiri KuzinTo get the best performances:
41a7c86884SShiri Kuzin
42a7c86884SShiri Kuzin- Verbs is a complete high-level generic API.
43a7c86884SShiri Kuzin- Direct Verbs is a device-specific API.
44a7c86884SShiri Kuzin- DevX allows to access firmware objects.
45a7c86884SShiri Kuzin
46a7c86884SShiri KuzinEnabling ``librte_crypto_mlx5`` causes DPDK applications
47a7c86884SShiri Kuzinto be linked against libibverbs.
48a7c86884SShiri Kuzin
49debb27eaSShiri KuzinIn order to move the device to crypto operational mode, credential and KEK
50debb27eaSShiri Kuzin(Key Encrypting Key) should be set as the first step.
51debb27eaSShiri KuzinThe credential will be used by the software in order to perform crypto login, and the KEK is
52debb27eaSShiri Kuzinthe AES Key Wrap Algorithm (rfc3394) key that will be used for sensitive data
53debb27eaSShiri Kuzinwrapping.
54debb27eaSShiri KuzinThe credential and the AES-XTS keys should be provided to the hardware, as ciphertext
55debb27eaSShiri Kuzinencrypted by the KEK.
56debb27eaSShiri Kuzin
57e8db4413SSuanming MouA keytag (64 bits) should be appended to the AES-XTS keys (before wrapping),
58e8db4413SSuanming Mouand will be validated when the hardware attempts to access it.
59e8db4413SSuanming Mou
60debb27eaSShiri KuzinWhen crypto engines are defined to work in wrapped import method, they come out
61debb27eaSShiri Kuzinof the factory in Commissioning mode, and thus, cannot be used for crypto operations
62debb27eaSShiri Kuzinyet. A dedicated tool is used for changing the mode from Commissioning to
63debb27eaSShiri KuzinOperational, while setting the first import_KEK and credential in plaintext.
64debb27eaSShiri KuzinThe mlxreg dedicated tool should be used as follows:
65debb27eaSShiri Kuzin
66debb27eaSShiri Kuzin- Set CRYPTO_OPERATIONAL register to set the device in crypto operational mode.
67debb27eaSShiri Kuzin
68debb27eaSShiri Kuzin  The input to this tool is:
69debb27eaSShiri Kuzin
70debb27eaSShiri Kuzin  - The first credential in plaintext, 40B.
71debb27eaSShiri Kuzin  - The first import_KEK in plaintext: kek size 0 for 16B or 1 for 32B, kek data.
72debb27eaSShiri Kuzin
73debb27eaSShiri Kuzin  Example::
74debb27eaSShiri Kuzin
75debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
76debb27eaSShiri Kuzin
77debb27eaSShiri Kuzin  The "wrapped_crypto_operational" value will be "0x00000000".
78debb27eaSShiri Kuzin  The command to set the register should be executed only once, and all the
79debb27eaSShiri Kuzin  values mentioned above should be specified in the same command.
80debb27eaSShiri Kuzin
81debb27eaSShiri Kuzin  Example::
82debb27eaSShiri Kuzin
83debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL \
84debb27eaSShiri Kuzin     --set "credential[0]=0x10000000, credential[1]=0x10000000, kek[0]=0x00000000"
85debb27eaSShiri Kuzin
86debb27eaSShiri Kuzin  All values not specified will remain 0.
87debb27eaSShiri Kuzin  "wrapped_crypto_going_to_commissioning" and  "wrapped_crypto_operational"
88debb27eaSShiri Kuzin  should not be specified.
89debb27eaSShiri Kuzin
90debb27eaSShiri Kuzin  All the device ports should set it in order to move to operational mode.
91debb27eaSShiri Kuzin
92debb27eaSShiri Kuzin- Query CRYPTO_OPERATIONAL register to make sure the device is in Operational
93debb27eaSShiri Kuzin  mode.
94debb27eaSShiri Kuzin
95debb27eaSShiri Kuzin  Example::
96debb27eaSShiri Kuzin
97debb27eaSShiri Kuzin     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
98debb27eaSShiri Kuzin
99debb27eaSShiri Kuzin  The "wrapped_crypto_operational" value will be "0x00000001" if the mode was
100debb27eaSShiri Kuzin  successfully changed to operational mode.
101debb27eaSShiri Kuzin
102a7c86884SShiri Kuzin
103a7c86884SShiri KuzinDriver options
104a7c86884SShiri Kuzin--------------
105a7c86884SShiri Kuzin
106a7c86884SShiri Kuzin- ``class`` parameter [string]
107a7c86884SShiri Kuzin
108a7c86884SShiri Kuzin  Select the class of the driver that should probe the device.
109a7c86884SShiri Kuzin  `crypto` for the mlx5 crypto driver.
110a7c86884SShiri Kuzin
111debb27eaSShiri Kuzin- ``wcs_file`` parameter [string] - mandatory
112debb27eaSShiri Kuzin
113debb27eaSShiri Kuzin  File path including only the wrapped credential in string format of hexadecimal
114debb27eaSShiri Kuzin  numbers, represent 48 bytes (8 bytes IV added by the AES key wrap algorithm).
115debb27eaSShiri Kuzin
116debb27eaSShiri Kuzin- ``import_kek_id`` parameter [int]
117debb27eaSShiri Kuzin
118debb27eaSShiri Kuzin  The identifier of the KEK, default value is 0 represents the operational
119debb27eaSShiri Kuzin  register import_kek..
120debb27eaSShiri Kuzin
121debb27eaSShiri Kuzin- ``credential_id`` parameter [int]
122debb27eaSShiri Kuzin
123debb27eaSShiri Kuzin  The identifier of the credential, default value is 0 represents the operational
124debb27eaSShiri Kuzin  register credential.
125debb27eaSShiri Kuzin
126e8db4413SSuanming Mou- ``keytag`` parameter [int]
127e8db4413SSuanming Mou
128e8db4413SSuanming Mou  The plaintext of the keytag appanded to the AES-XTS keys, default value is 0.
129e8db4413SSuanming Mou
130*a1978aa2SSuanming Mou- ``max_segs_num`` parameter [int]
131*a1978aa2SSuanming Mou
132*a1978aa2SSuanming Mou  Maximum number of mbuf chain segments(src or dest), default value is 8.
133*a1978aa2SSuanming Mou
134a7c86884SShiri Kuzin
135a7c86884SShiri KuzinSupported NICs
136a7c86884SShiri Kuzin--------------
137a7c86884SShiri Kuzin
138a7c86884SShiri Kuzin* Mellanox\ |reg| ConnectX\ |reg|-6 200G MCX654106A-HCAT (2x200G)
139a7c86884SShiri Kuzin
1401004be3cSShiri Kuzin
1411004be3cSShiri KuzinLimitations
1421004be3cSShiri Kuzin-----------
1431004be3cSShiri Kuzin
1441004be3cSShiri Kuzin- AES-XTS keys provided in xform must include keytag and should be wrapped.
1451004be3cSShiri Kuzin- The supported data-unit lengths are 512B and 1KB. In case the `dataunit_len`
1461004be3cSShiri Kuzin  is not provided in the cipher xform, the OP length is limited to the above
1471004be3cSShiri Kuzin  values and 1MB.
1481004be3cSShiri Kuzin
1491004be3cSShiri Kuzin
150a7c86884SShiri KuzinPrerequisites
151a7c86884SShiri Kuzin-------------
152a7c86884SShiri Kuzin
153a7c86884SShiri Kuzin- Mellanox OFED version: **5.3**
154a7c86884SShiri Kuzin  see :doc:`../../nics/mlx5` guide for more Mellanox OFED details.
155a7c86884SShiri Kuzin
156a7c86884SShiri Kuzin- Compilation can be done also with rdma-core v15+.
157a7c86884SShiri Kuzin  see :doc:`../../nics/mlx5` guide for more rdma-core details.
158