Skip to content

Commit

Permalink
crypto/mlx5: introduce Mellanox crypto driver
Browse files Browse the repository at this point in the history
Add a new PMD for Mellanox devices- crypto PMD.

The crypto PMD will be supported starting Nvidia ConnectX6 and
BlueField2.

The crypto PMD will add the support of encryption and decryption using
the AES-XTS symmetric algorithm.

The crypto PMD requires rdma-core and uses mlx5 DevX.

This patch adds the PCI probing, basic functions, build files and
log utility.

Signed-off-by: Shiri Kuzin <[email protected]>
Acked-by: Matan Azrad <[email protected]>
Acked-by: Akhil Goyal <[email protected]>
  • Loading branch information
Shiri Kuzin authored and Akhil Goyal committed Jul 20, 2021
1 parent 6425d95 commit a7c8688
Show file tree
Hide file tree
Showing 13 changed files with 463 additions and 10 deletions.
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,12 @@ F: drivers/crypto/octeontx2/
F: doc/guides/cryptodevs/octeontx2.rst
F: doc/guides/cryptodevs/features/octeontx2.ini

Mellanox mlx5
M: Matan Azrad <[email protected]>
F: drivers/crypto/mlx5/
F: doc/guides/cryptodevs/mlx5.rst
F: doc/guides/cryptodevs/features/mlx5.ini

Null Crypto
M: Declan Doherty <[email protected]>
F: drivers/crypto/null/
Expand Down
27 changes: 27 additions & 0 deletions doc/guides/cryptodevs/features/mlx5.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
;
; Features of a mlx5 crypto driver.
;
; Refer to default.ini for the full list of available PMD features.
;
[Features]
HW Accelerated = Y

;
; Supported crypto algorithms of a mlx5 crypto driver.
;
[Cipher]

;
; Supported authentication algorithms of a mlx5 crypto driver.
;
[Auth]

;
; Supported AEAD algorithms of a mlx5 crypto driver.
;
[AEAD]

;
; Supported Asymmetric algorithms of a mlx5 crypto driver.
;
[Asymmetric]
1 change: 1 addition & 0 deletions doc/guides/cryptodevs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Crypto Device Drivers
octeontx
octeontx2
openssl
mlx5
mvsam
nitrox
null
Expand Down
65 changes: 65 additions & 0 deletions doc/guides/cryptodevs/mlx5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.. SPDX-License-Identifier: BSD-3-Clause
Copyright (c) 2021 NVIDIA Corporation & Affiliates
.. include:: <isonum.txt>

MLX5 Crypto Driver
==================

The MLX5 crypto driver library
(**librte_crypto_mlx5**) provides support for **Mellanox ConnectX-6**
family adapters.

Overview
--------

The device can provide disk encryption services,
allowing data encryption and decryption towards a disk.
Having all encryption/decryption operations done in a single device
can reduce cost and overheads of the related FIPS certification,
as ConnectX-6 is FIPS 140-2 level-2 ready.
The encryption cipher is AES-XTS of 256/512 bit key size.

MKEY is a memory region object in the hardware,
that holds address translation information and attributes per memory area.
Its ID must be tied to addresses provided to the hardware.
The encryption operations are performed with MKEY read/write transactions,
when the MKEY is configured to perform crypto operations.

The encryption does not require text to be aligned to the AES block size (128b).

The PMD uses ``libibverbs`` and ``libmlx5`` to access the device firmware
or to access the hardware components directly.
There are different levels of objects and bypassing abilities.
To get the best performances:

- Verbs is a complete high-level generic API.
- Direct Verbs is a device-specific API.
- DevX allows to access firmware objects.

Enabling ``librte_crypto_mlx5`` causes DPDK applications
to be linked against libibverbs.


Driver options
--------------

- ``class`` parameter [string]

Select the class of the driver that should probe the device.
`crypto` for the mlx5 crypto driver.


Supported NICs
--------------

* Mellanox\ |reg| ConnectX\ |reg|-6 200G MCX654106A-HCAT (2x200G)

Prerequisites
-------------

- Mellanox OFED version: **5.3**
see :doc:`../../nics/mlx5` guide for more Mellanox OFED details.

- Compilation can be done also with rdma-core v15+.
see :doc:`../../nics/mlx5` guide for more rdma-core details.
1 change: 1 addition & 0 deletions drivers/common/mlx5/mlx5_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ enum mlx5_class {
MLX5_CLASS_VDPA = RTE_BIT64(1),
MLX5_CLASS_REGEX = RTE_BIT64(2),
MLX5_CLASS_COMPRESS = RTE_BIT64(3),
MLX5_CLASS_CRYPTO = RTE_BIT64(4),
};

#define MLX5_DBR_SIZE RTE_CACHE_LINE_SIZE
Expand Down
14 changes: 14 additions & 0 deletions drivers/common/mlx5/mlx5_common_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,34 @@ static const struct {
{ .name = "net", .driver_class = MLX5_CLASS_NET },
{ .name = "regex", .driver_class = MLX5_CLASS_REGEX },
{ .name = "compress", .driver_class = MLX5_CLASS_COMPRESS },
{ .name = "crypto", .driver_class = MLX5_CLASS_CRYPTO },
};

static const unsigned int mlx5_class_combinations[] = {
MLX5_CLASS_NET,
MLX5_CLASS_VDPA,
MLX5_CLASS_REGEX,
MLX5_CLASS_COMPRESS,
MLX5_CLASS_CRYPTO,
MLX5_CLASS_NET | MLX5_CLASS_REGEX,
MLX5_CLASS_VDPA | MLX5_CLASS_REGEX,
MLX5_CLASS_NET | MLX5_CLASS_COMPRESS,
MLX5_CLASS_VDPA | MLX5_CLASS_COMPRESS,
MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS,
MLX5_CLASS_NET | MLX5_CLASS_CRYPTO,
MLX5_CLASS_VDPA | MLX5_CLASS_CRYPTO,
MLX5_CLASS_REGEX | MLX5_CLASS_CRYPTO,
MLX5_CLASS_COMPRESS | MLX5_CLASS_CRYPTO,
MLX5_CLASS_NET | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS,
MLX5_CLASS_VDPA | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS,
MLX5_CLASS_NET | MLX5_CLASS_REGEX | MLX5_CLASS_CRYPTO,
MLX5_CLASS_VDPA | MLX5_CLASS_REGEX | MLX5_CLASS_CRYPTO,
MLX5_CLASS_NET | MLX5_CLASS_COMPRESS | MLX5_CLASS_CRYPTO,
MLX5_CLASS_VDPA | MLX5_CLASS_COMPRESS | MLX5_CLASS_CRYPTO,
MLX5_CLASS_NET | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS |
MLX5_CLASS_CRYPTO,
MLX5_CLASS_VDPA | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS |
MLX5_CLASS_CRYPTO,
/* New class combination should be added here. */
};

Expand Down
21 changes: 11 additions & 10 deletions drivers/common/mlx5/mlx5_common_pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
* @file
*
* RTE Mellanox PCI Driver Interface
* Mellanox ConnectX PCI device supports multiple class: net,vdpa,regex and
* compress devices. This layer enables creating such multiple class of devices
* on a single PCI device by allowing to bind multiple class specific device
* driver to attach to mlx5_pci driver.
* Mellanox ConnectX PCI device supports multiple class: net,vdpa,regex,compress
* and crypto devices. This layer enables creating such multiple class of
* devices on a single PCI device by allowing to bind multiple class specific
* device driver to attach to mlx5_pci driver.
*
* ----------- ------------ ------------- ----------------
* | mlx5 | | mlx5 | | mlx5 | | mlx5 |
* | net pmd | | vdpa pmd | | regex pmd | | compress pmd |
* ----------- ------------ ------------- ----------------
* \ \ / /
* \ \ / /
* -------- -------- --------- ------------ ----------
* | mlx5 | | mlx5 | | mlx5 | | mlx5 | | mlx5 |
* | net | | vdpa | | regex | | compress | | crypto |
* | pmd | | pmd | | pmd | | pmd | | pmd |
* -------- -------- --------- ------------ ----------
* \ \ | / /
* \ \ | / /
* \ \_--------------_/ /
* \_______________| mlx5 |_______________/
* | pci common |
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ drivers = [
'dpaa_sec',
'dpaa2_sec',
'kasumi',
'mlx5',
'mvsam',
'nitrox',
'null',
Expand Down
27 changes: 27 additions & 0 deletions drivers/crypto/mlx5/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2021 NVIDIA Corporation & Affiliates

if not is_linux
build = false
reason = 'only supported on Linux'
subdir_done()
endif

fmt_name = 'mlx5_crypto'
deps += ['common_mlx5', 'eal', 'cryptodev']
sources = files(
'mlx5_crypto.c',
)

cflags_options = [
'-std=c11',
'-Wno-strict-prototypes',
'-D_BSD_SOURCE',
'-D_DEFAULT_SOURCE',
'-D_XOPEN_SOURCE=600',
]
foreach option:cflags_options
if cc.has_argument(option)
cflags += option
endif
endforeach
Loading

0 comments on commit a7c8688

Please sign in to comment.