module/accel: Add accel_dpdk_cryptodev
The new module replaces functionality in vbdev_crypto. This module is bdev agnostic, so some inernal parts were reworked. io_channel: contains a qp of every configured DPDK PMD crypto key: for mlx5_pci we register a key on each available device since keys are bound to Protection Domain. Signed-off-by: Alexey Marchuk <alexeymar@nvidia.com> Change-Id: If1845cb87eadacbb921c593ba82207a97f2209a3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14859 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
f5d1a924a1
commit
61fbb000fe
@ -8,6 +8,9 @@ New library isa-l-crypto has been added, it is used by accel library in crypto o
|
||||
|
||||
New functions `spdk_accel_submit_encrypt` and `spdk_accel_submit_decrypt` were added.
|
||||
|
||||
New accel module `dpdk_cryptodev` has been added. It uses DPDK crypto PMD and support encrypt and
|
||||
decrypt operations. New RPC `dpdk_cryptodev_scan_accel_module` has been added to enable this accel module.
|
||||
|
||||
### bdev
|
||||
|
||||
Both of interleaved and separated metadata are now supported by the malloc bdev module.
|
||||
|
@ -86,7 +86,7 @@ The DSA hardware supports a limited queue depth and channels. This means that
|
||||
only a limited number of `spdk_thread`s will be able to acquire a channel.
|
||||
Design software to deal with the inability to get a channel.
|
||||
|
||||
### How to use kernel idxd driver {#accel_idxd_kernel}
|
||||
#### How to use kernel idxd driver {#accel_idxd_kernel}
|
||||
|
||||
There are several dependencies to leverage the Linux idxd driver for driving DSA devices.
|
||||
|
||||
@ -139,6 +139,22 @@ enabled via startup RPC as discussed earlier, the software module will use ISA-L
|
||||
if available for functions such as CRC32C. Otherwise, standard glibc calls are
|
||||
used to back the framework API.
|
||||
|
||||
### dpdk_cryptodev {#accel_dpdk_cryptodev}
|
||||
|
||||
The dpdk_cryptodev module uses DPDK CryptoDev API to implement crypto operations.
|
||||
The following ciphers and PMDs are supported:
|
||||
|
||||
- AESN-NI Multi Buffer Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC
|
||||
- Intel(R) QuickAssist (QAT) Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC,
|
||||
RTE_CRYPTO_CIPHER_AES128_XTS
|
||||
(Note: QAT is functional however is marked as experimental until the hardware has
|
||||
been fully integrated with the SPDK CI system.)
|
||||
- MLX5 Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES256_XTS, RTE_CRYPTO_CIPHER_AES512_XTS
|
||||
|
||||
To enable this module, use [`dpdk_cryptodev_scan_accel_module`](https://spdk.io/doc/jsonrpc.html),
|
||||
this RPC is available in STARTUP state and the SPDK application needs to be run with `--wait-for-rpc`
|
||||
CLI parameter. To select a specific PMD, use [`dpdk_cryptodev_set_driver`](https://spdk.io/doc/jsonrpc.html)
|
||||
|
||||
### Module to Operation Code Assignment {#accel_assignments}
|
||||
|
||||
When multiple modules are initialized, the accel framework will assign op codes to
|
||||
|
@ -446,6 +446,9 @@ Example response:
|
||||
"accel_crypto_keys_get",
|
||||
"ioat_scan_accel_module",
|
||||
"dsa_scan_accel_module",
|
||||
"dpdk_cryptodev_scan_accel_module",
|
||||
"dpdk_cryptodev_set_driver",
|
||||
"dpdk_cryptodev_get_driver",
|
||||
"bdev_virtio_attach_controller",
|
||||
"bdev_virtio_scsi_get_devices",
|
||||
"bdev_virtio_detach_controller",
|
||||
@ -1961,6 +1964,101 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
### dpdk_cryptodev_scan_accel_module {#rpc_dpdk_cryptodev_scan_accel_module}
|
||||
|
||||
Enable dpdk_cryptodev accel offload
|
||||
|
||||
#### Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "dpdk_cryptodev_scan_accel_module",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": true
|
||||
}
|
||||
~~~
|
||||
|
||||
### dpdk_cryptodev_set_driver {#rpc_dpdk_cryptodev_set_driver}
|
||||
|
||||
Set the DPDK cryptodev driver
|
||||
|
||||
#### Parameters
|
||||
|
||||
Name | Optional | Type | Description
|
||||
----------------------- |----------|--------| -----------
|
||||
driver_name | Required | string | The driver, can be one of crypto_aesni_mb, crypto_qat or mlx5_pci
|
||||
|
||||
#### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "dpdk_cryptodev_set_driver",
|
||||
"id": 1,
|
||||
"params": {
|
||||
"driver_name": "crypto_aesni_mb"
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": true
|
||||
}
|
||||
~~~
|
||||
|
||||
### dpdk_cryptodev_get_driver {#rpc_dpdk_cryptodev_get_driver}
|
||||
|
||||
Get the DPDK cryptodev driver
|
||||
|
||||
#### Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "dpdk_cryptodev_get_driver",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": "crypto_aesni_mb"
|
||||
}
|
||||
~~~
|
||||
|
||||
## Block Device Abstraction Layer {#jsonrpc_components_bdev}
|
||||
|
||||
### bdev_set_options {#rpc_bdev_set_options}
|
||||
|
@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (C) 2015 Intel Corporation.
|
||||
# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
@ -96,6 +97,7 @@ endif
|
||||
DEPDIRS-accel_ioat := log ioat thread jsonrpc rpc accel
|
||||
DEPDIRS-accel_dsa := log idxd thread $(JSON_LIBS) accel trace
|
||||
DEPDIRS-accel_iaa := log idxd thread $(JSON_LIBS) accel trace
|
||||
DEPDIRS-accel_dpdk_cryptodev := log thread $(JSON_LIBS) accel
|
||||
|
||||
# module/env_dpdk
|
||||
DEPDIRS-env_dpdk_rpc := log $(JSON_LIBS)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (C) 2016 Intel Corporation.
|
||||
# Copyright (c) 2021, 2022 NVIDIA CORPORATION & AFFILIATES.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
#
|
||||
|
||||
BLOCKDEV_MODULES_LIST = bdev_malloc bdev_null bdev_nvme bdev_passthru bdev_lvol
|
||||
@ -101,6 +101,9 @@ ACCEL_MODULES_LIST = accel_ioat ioat
|
||||
ifeq ($(CONFIG_IDXD),y)
|
||||
ACCEL_MODULES_LIST += accel_dsa accel_iaa idxd
|
||||
endif
|
||||
ifeq ($(CONFIG_CRYPTO),y)
|
||||
ACCEL_MODULES_LIST += accel_dpdk_cryptodev
|
||||
endif
|
||||
|
||||
SCHEDULER_MODULES_LIST = scheduler_dynamic
|
||||
ifeq (y,$(DPDK_POWER))
|
||||
|
@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (C) 2015 Intel Corporation.
|
||||
# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
@ -10,6 +11,7 @@ DIRS-y = ioat
|
||||
|
||||
DIRS-$(CONFIG_IDXD) += dsa
|
||||
DIRS-$(CONFIG_IDXD) += iaa
|
||||
DIRS-$(CONFIG_CRYPTO) += dpdk_cryptodev
|
||||
|
||||
.PHONY: all clean $(DIRS-y)
|
||||
|
||||
|
20
module/accel/dpdk_cryptodev/Makefile
Normal file
20
module/accel/dpdk_cryptodev/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (c) Intel Corporation.
|
||||
# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 1
|
||||
SO_MINOR := 0
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS)
|
||||
|
||||
LIBNAME = accel_dpdk_cryptodev
|
||||
C_SRCS = accel_dpdk_cryptodev.c accel_dpdk_cryptodev_rpc.c
|
||||
|
||||
SPDK_MAP_FILE = $(SPDK_ROOT_DIR)/mk/spdk_blank.map
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
File diff suppressed because it is too large
Load Diff
16
module/accel/dpdk_cryptodev/accel_dpdk_cryptodev.h
Normal file
16
module/accel/dpdk_cryptodev/accel_dpdk_cryptodev.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_ACCEL_DPDK_CRYPTODEV_H
|
||||
#define SPDK_ACCEL_DPDK_CRYPTODEV_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
void accel_dpdk_cryptodev_enable(void);
|
||||
int accel_dpdk_cryptodev_set_driver(const char *driver_name);
|
||||
const char *accel_dpdk_cryptodev_get_driver(void);
|
||||
|
||||
#endif /* SPDK_ACCEL_DPDK_CRYPTODEV_H */
|
82
module/accel/dpdk_cryptodev/accel_dpdk_cryptodev_rpc.c
Normal file
82
module/accel/dpdk_cryptodev/accel_dpdk_cryptodev_rpc.c
Normal file
@ -0,0 +1,82 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "accel_dpdk_cryptodev.h"
|
||||
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/util.h"
|
||||
|
||||
static void
|
||||
rpc_dpdk_cryptodev_scan_accel_module(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
if (params != NULL) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"No parameters expected");
|
||||
return;
|
||||
}
|
||||
|
||||
accel_dpdk_cryptodev_enable();
|
||||
spdk_jsonrpc_send_bool_response(request, true);
|
||||
}
|
||||
SPDK_RPC_REGISTER("dpdk_cryptodev_scan_accel_module", rpc_dpdk_cryptodev_scan_accel_module,
|
||||
SPDK_RPC_STARTUP)
|
||||
|
||||
struct rpc_set_driver {
|
||||
char *driver_name;
|
||||
};
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_set_driver_decoders[] = {
|
||||
{"driver_name", offsetof(struct rpc_set_driver, driver_name), spdk_json_decode_string},
|
||||
};
|
||||
|
||||
static void
|
||||
rpc_dpdk_cryptodev_set_driver(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_set_driver req = {};
|
||||
int rc;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_set_driver_decoders,
|
||||
SPDK_COUNTOF(rpc_set_driver_decoders), &req)) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_PARSE_ERROR,
|
||||
"spdk_json_decode_object failed");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = accel_dpdk_cryptodev_set_driver(req.driver_name);
|
||||
free(req.driver_name);
|
||||
if (rc) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"incorrect driver name");
|
||||
} else {
|
||||
spdk_jsonrpc_send_bool_response(request, true);
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("dpdk_cryptodev_set_driver", rpc_dpdk_cryptodev_set_driver, SPDK_RPC_STARTUP)
|
||||
|
||||
static void
|
||||
rpc_dpdk_cryptodev_get_driver(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
const char *driver_name;
|
||||
|
||||
if (params) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"No parameters expected");
|
||||
return;
|
||||
}
|
||||
|
||||
driver_name = accel_dpdk_cryptodev_get_driver();
|
||||
assert(driver_name);
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_string(w, driver_name);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("dpdk_cryptodev_get_driver", rpc_dpdk_cryptodev_get_driver,
|
||||
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
@ -31,6 +31,7 @@ from . import vmd
|
||||
from . import sock
|
||||
from . import vfio_user
|
||||
from . import iobuf
|
||||
from . import dpdk_cryptodev
|
||||
from . import client as rpc_client
|
||||
|
||||
|
||||
|
25
python/spdk/rpc/dpdk_cryptodev.py
Normal file
25
python/spdk/rpc/dpdk_cryptodev.py
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
# All rights reserved.
|
||||
|
||||
def dpdk_cryptodev_scan_accel_module(client):
|
||||
"""Enable dpdk_cryptodev accel module.
|
||||
"""
|
||||
return client.call('dpdk_cryptodev_scan_accel_module')
|
||||
|
||||
|
||||
def dpdk_cryptodev_set_driver(client, driver_name):
|
||||
"""Set the DPDK cryptodev driver.
|
||||
|
||||
Args:
|
||||
driver_name: The driver, can be one of crypto_aesni_mb, crypto_qat or mlx5_pci
|
||||
"""
|
||||
params = {'driver_name': driver_name}
|
||||
|
||||
return client.call('dpdk_cryptodev_set_driver', params)
|
||||
|
||||
|
||||
def dpdk_cryptodev_get_driver(client):
|
||||
"""Get the DPDK cryptodev driver.
|
||||
"""
|
||||
return client.call('dpdk_cryptodev_get_driver')
|
@ -2839,6 +2839,28 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
help='Set config and enable iaa accel module offload.')
|
||||
p.set_defaults(func=iaa_scan_accel_module)
|
||||
|
||||
def dpdk_cryptodev_scan_accel_module(args):
|
||||
rpc.dpdk_cryptodev.dpdk_cryptodev_scan_accel_module(args.client)
|
||||
|
||||
p = subparsers.add_parser('dpdk_cryptodev_scan_accel_module',
|
||||
help='Enable dpdk_cryptodev accel module offload.')
|
||||
p.set_defaults(func=dpdk_cryptodev_scan_accel_module)
|
||||
|
||||
def dpdk_cryptodev_set_driver(args):
|
||||
rpc.dpdk_cryptodev.dpdk_cryptodev_set_driver(args.client,
|
||||
driver_name=args.driver_name)
|
||||
|
||||
p = subparsers.add_parser('dpdk_cryptodev_set_driver',
|
||||
help='Set the DPDK cryptodev driver.')
|
||||
p.add_argument('-d', '--driver-name', help='The driver, can be one of crypto_aesni_mb, crypto_qat or mlx5_pci', type=str)
|
||||
p.set_defaults(func=dpdk_cryptodev_set_driver)
|
||||
|
||||
def dpdk_cryptodev_get_driver(args):
|
||||
print_dict(rpc.dpdk_cryptodev.dpdk_cryptodev_get_driver(args.client))
|
||||
|
||||
p = subparsers.add_parser('dpdk_cryptodev_get_driver', help='Get the DPDK cryptodev driver')
|
||||
p.set_defaults(func=dpdk_cryptodev_get_driver)
|
||||
|
||||
# opal
|
||||
def bdev_nvme_opal_init(args):
|
||||
rpc.nvme.bdev_nvme_opal_init(args.client,
|
||||
|
@ -56,7 +56,3 @@ module/bdev/daos/bdev_daos_rpc
|
||||
# Not configured to test xNVMe bdev
|
||||
module/bdev/xnvme/bdev_xnvme
|
||||
module/bdev/xnvme/bdev_xnvme_rpc
|
||||
|
||||
# Temporary added, will be remove in the next patch
|
||||
module/accel/dpdk_cryptodev/accel_dpdk_cryptodev
|
||||
test/unit/lib/accel/dpdk_cryptodev.c/accel_dpdk_cryptodev_ut
|
||||
|
@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (C) 2015 Intel Corporation.
|
||||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
@ -7,6 +8,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
DIRS-y = accel.c
|
||||
DIRS-$(CONFIG_CRYPTO) += dpdk_cryptodev.c
|
||||
|
||||
.PHONY: all clean $(DIRS-y)
|
||||
|
||||
|
11
test/unit/lib/accel/dpdk_cryptodev.c/Makefile
Normal file
11
test/unit/lib/accel/dpdk_cryptodev.c/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
|
||||
|
||||
TEST_FILE = accel_dpdk_cryptodev_ut.c
|
||||
CFLAGS += $(ENV_CFLAGS)
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.unittest.mk
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user