xref: /dpdk/doc/guides/cryptodevs/mlx5.rst (revision af0785a2447b307965377b62f46a5f39457a85a3)
1.. SPDX-License-Identifier: BSD-3-Clause
2   Copyright (c) 2021 NVIDIA Corporation & Affiliates
3
4.. include:: <isonum.txt>
5
6NVIDIA MLX5 Crypto Driver
7=========================
8
9.. note::
10
11   NVIDIA acquired Mellanox Technologies in 2020.
12   The DPDK documentation and code might still include instances
13   of or references to Mellanox trademarks (like BlueField and ConnectX)
14   that are now NVIDIA trademarks.
15
16The MLX5 crypto driver library
17(**librte_crypto_mlx5**) provides support for **NVIDIA ConnectX-6**
18family adapters.
19
20Overview
21--------
22
23The device can provide disk encryption services,
24allowing data encryption and decryption towards a disk.
25Having all encryption/decryption operations done in a single device
26can reduce cost and overheads of the related FIPS certification,
27as ConnectX-6 is FIPS 140-2 level-2 ready.
28The encryption cipher is AES-XTS of 256/512 bit key size.
29
30MKEY is a memory region object in the hardware,
31that holds address translation information and attributes per memory area.
32Its ID must be tied to addresses provided to the hardware.
33The encryption operations are performed with MKEY read/write transactions,
34when the MKEY is configured to perform crypto operations.
35
36The encryption does not require text to be aligned to the AES block size (128b).
37
38See :doc:`../../platform/mlx5` guide for more design details.
39
40Configuration
41-------------
42
43See the :ref:`mlx5 common configuration <mlx5_common_env>`.
44
45A device comes out of NVIDIA factory with pre-defined import methods.
46There are two possible import methods: wrapped or plaintext.
47
48In case the device is in wrapped mode, it needs to be moved to crypto operational mode.
49In order to move the device to crypto operational mode, credential and KEK
50(Key Encrypting Key) should be set as the first step.
51The credential will be used by the software in order to perform crypto login, and the KEK is
52the AES Key Wrap Algorithm (rfc3394) key that will be used for sensitive data
53wrapping.
54The credential and the AES-XTS keys should be provided to the hardware, as ciphertext
55encrypted by the KEK.
56
57A keytag (64 bits) should be appended to the AES-XTS keys (before wrapping),
58and will be validated when the hardware attempts to access it.
59
60When crypto engines are defined to work in wrapped import method, they come out
61of the factory in Commissioning mode, and thus, cannot be used for crypto operations
62yet. A dedicated tool is used for changing the mode from Commissioning to
63Operational, while setting the first import_KEK and credential in plaintext.
64The mlxreg dedicated tool should be used as follows:
65
66- Set CRYPTO_OPERATIONAL register to set the device in crypto operational mode.
67
68  The input to this tool is:
69
70  - The first credential in plaintext, 40B.
71  - The first import_KEK in plaintext: kek size 0 for 16B or 1 for 32B, kek data.
72
73  Example::
74
75     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
76
77  The "wrapped_crypto_operational" value will be "0x00000000".
78  The command to set the register should be executed only once, and all the
79  values mentioned above should be specified in the same command.
80
81  Example::
82
83     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL \
84     --set "credential[0]=0x10000000, credential[1]=0x10000000, kek[0]=0x00000000"
85
86  All values not specified will remain 0.
87  "wrapped_crypto_going_to_commissioning" and  "wrapped_crypto_operational"
88  should not be specified.
89
90  All the device ports should set it in order to move to operational mode.
91  For BlueField-2, the internal ports in the ARM system should also be set.
92
93- Query CRYPTO_OPERATIONAL register to make sure the device is in Operational
94  mode.
95
96  Example::
97
98     mlxreg -d /dev/mst/mt4123_pciconf0 --reg_name CRYPTO_OPERATIONAL --get
99
100  The "wrapped_crypto_operational" value will be "0x00000001" if the mode was
101  successfully changed to operational mode.
102
103On the other hand, in case of plaintext mode, there is no need for all the above,
104DEK is passed in plaintext without keytag.
105
106  The mlx5 crypto PMD can be verified by running the test application::
107    Wrapped mode:
108      dpdk-test -c 1 -n 1 -w <dev>,class=crypto,wcs_file=<file_path>
109      RTE>>cryptodev_mlx5_autotest
110
111    Plaintext mode:
112      dpdk-test -c 1 -n 1 -w <dev>,class=crypto
113      RTE>>cryptodev_mlx5_autotest
114
115
116Driver options
117--------------
118
119Please refer to :ref:`mlx5 common options <mlx5_common_driver_options>`
120for an additional list of options shared with other mlx5 drivers.
121
122- ``wcs_file`` parameter [string] - mandatory in wrapped mode
123
124  File path including only the wrapped credential in string format of hexadecimal
125  numbers, represent 48 bytes (8 bytes IV added by the AES key wrap algorithm).
126
127- ``import_kek_id`` parameter [int]
128
129  The identifier of the KEK, default value is 0 represents the operational
130  register import_kek..
131
132- ``credential_id`` parameter [int]
133
134  The identifier of the credential, default value is 0 represents the operational
135  register credential.
136
137- ``keytag`` parameter [int]
138
139  The plaintext of the keytag appended to the AES-XTS keys, default value is 0.
140
141- ``max_segs_num`` parameter [int]
142
143  Maximum number of mbuf chain segments(src or dest), default value is 8.
144
145
146Supported NICs
147--------------
148
149* NVIDIA\ |reg| ConnectX\ |reg|-6 200G MCX654106A-HCAT (2x200G)
150* NVIDIA\ |reg| ConnectX\ |reg|-6 Dx
151* NVIDIA\ |reg| BlueField-2 SmartNIC
152
153
154Limitations
155-----------
156
157- AES-XTS keys provided in xform must include keytag and should be wrapped.
158- The supported data-unit lengths are 512B and 4KB and 1MB. In case the `dataunit_len`
159  is not provided in the cipher xform, the OP length is limited to the above
160  values.
161
162
163Prerequisites
164-------------
165
166FW Prerequisites
167~~~~~~~~~~~~~~~~
168
169- xx.31.0328 for ConnectX-6.
170- xx.32.0108 for ConnectX-6 Dx and BlueField-2.
171
172Linux Prerequisites
173~~~~~~~~~~~~~~~~~~~
174
175- NVIDIA MLNX_OFED version: **5.3**.
176- Compilation can be done also with rdma-core v15+.
177
178  See :ref:`mlx5 common prerequisites <mlx5_linux_prerequisites>` for more details.
179
180Windows Prerequisites
181~~~~~~~~~~~~~~~~~~~~~
182
183- NVIDIA WINOF-2 version: **2.60** or higher.
184  See :ref:`mlx5 common prerequisites <mlx5_windows_prerequisites>` for more details.
185