2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2018 Intel Corporation.
|
2018-03-07 23:44:06 +00:00
|
|
|
* All rights reserved.
|
2022-03-11 12:15:57 +00:00
|
|
|
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
|
|
|
|
* All rights reserved.
|
2018-03-07 23:44:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_VBDEV_CRYPTO_H
|
|
|
|
#define SPDK_VBDEV_CRYPTO_H
|
|
|
|
|
|
|
|
#include "spdk/rpc.h"
|
|
|
|
#include "spdk/util.h"
|
|
|
|
#include "spdk/string.h"
|
2020-10-06 16:16:26 +00:00
|
|
|
#include "spdk/log.h"
|
2022-08-31 15:26:12 +00:00
|
|
|
#include "spdk/accel.h"
|
|
|
|
#include "spdk_internal/accel_module.h"
|
2018-03-07 23:44:06 +00:00
|
|
|
|
|
|
|
#include "spdk/bdev.h"
|
|
|
|
|
2022-08-31 15:26:12 +00:00
|
|
|
#define BDEV_CRYPTO_DEFAULT_CIPHER "AES_CBC" /* QAT and AESNI_MB */
|
2020-01-31 22:03:02 +00:00
|
|
|
|
2022-08-31 15:26:12 +00:00
|
|
|
/* Structure to hold crypto options */
|
2022-01-20 08:25:05 +00:00
|
|
|
struct vbdev_crypto_opts {
|
|
|
|
char *vbdev_name; /* name of the vbdev to create */
|
|
|
|
char *bdev_name; /* base bdev name */
|
2022-08-31 15:26:12 +00:00
|
|
|
struct spdk_accel_crypto_key *key; /* crypto key */
|
|
|
|
bool key_owner; /* If wet to true then the key was created by RPC and needs to be destroyed */
|
2022-01-20 08:25:05 +00:00
|
|
|
};
|
|
|
|
|
2018-03-07 23:44:06 +00:00
|
|
|
typedef void (*spdk_delete_crypto_complete)(void *cb_arg, int bdeverrno);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new crypto bdev.
|
|
|
|
*
|
2022-01-20 08:25:05 +00:00
|
|
|
* \param opts Crypto options populated by create_crypto_opts()
|
2018-03-07 23:44:06 +00:00
|
|
|
* \return 0 on success, other on failure.
|
|
|
|
*/
|
2022-01-20 08:25:05 +00:00
|
|
|
int create_crypto_disk(struct vbdev_crypto_opts *opts);
|
2018-03-07 23:44:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete crypto bdev.
|
|
|
|
*
|
2022-03-29 05:55:53 +00:00
|
|
|
* \param bdev_name Crypto bdev name.
|
2018-03-07 23:44:06 +00:00
|
|
|
* \param cb_fn Function to call after deletion.
|
|
|
|
* \param cb_arg Argument to pass to cb_fn.
|
|
|
|
*/
|
2022-03-29 05:55:53 +00:00
|
|
|
void delete_crypto_disk(const char *bdev_name, spdk_delete_crypto_complete cb_fn,
|
2018-03-07 23:44:06 +00:00
|
|
|
void *cb_arg);
|
|
|
|
|
2022-01-20 08:25:05 +00:00
|
|
|
/**
|
|
|
|
* Release crypto opts created with create_crypto_opts()
|
|
|
|
*
|
|
|
|
* \param opts Crypto opts to release
|
|
|
|
*/
|
|
|
|
void free_crypto_opts(struct vbdev_crypto_opts *opts);
|
|
|
|
|
2018-03-07 23:44:06 +00:00
|
|
|
#endif /* SPDK_VBDEV_CRYPTO_H */
|