xref: /spdk/module/bdev/crypto/vbdev_crypto.h (revision 5d2d59be8d1438aba90e0334c1accab35401b980)
1488570ebSJim Harris /*   SPDX-License-Identifier: BSD-3-Clause
2a6dbe372Spaul luse  *   Copyright (C) 2018 Intel Corporation.
307fe6a43SSeth Howell  *   All rights reserved.
41434e255SYuriy Umanets  *   Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.
51434e255SYuriy Umanets  *   All rights reserved.
607fe6a43SSeth Howell  */
707fe6a43SSeth Howell 
807fe6a43SSeth Howell #ifndef SPDK_VBDEV_CRYPTO_H
907fe6a43SSeth Howell #define SPDK_VBDEV_CRYPTO_H
1007fe6a43SSeth Howell 
1107fe6a43SSeth Howell #include "spdk/rpc.h"
1207fe6a43SSeth Howell #include "spdk/util.h"
1307fe6a43SSeth Howell #include "spdk/string.h"
144e8e97c8STomasz Zawadzki #include "spdk/log.h"
1513f97e67SAlexey Marchuk #include "spdk/accel.h"
16*5d2d59beSKonrad Sztyber #include "spdk/accel_module.h"
1707fe6a43SSeth Howell 
1807fe6a43SSeth Howell #include "spdk/bdev.h"
1907fe6a43SSeth Howell 
2013f97e67SAlexey Marchuk #define BDEV_CRYPTO_DEFAULT_CIPHER "AES_CBC" /* QAT and AESNI_MB */
21593cb5b3Spaul luse 
2213f97e67SAlexey Marchuk /* Structure to hold crypto options */
235ba9b78eSYuriy Umanets struct vbdev_crypto_opts {
245ba9b78eSYuriy Umanets 	char				*vbdev_name;	/* name of the vbdev to create */
255ba9b78eSYuriy Umanets 	char				*bdev_name;	/* base bdev name */
2613f97e67SAlexey Marchuk 	struct spdk_accel_crypto_key	*key;		/* crypto key */
2713f97e67SAlexey Marchuk 	bool				key_owner;	/* If wet to true then the key was created by RPC and needs to be destroyed */
285ba9b78eSYuriy Umanets };
295ba9b78eSYuriy Umanets 
3007fe6a43SSeth Howell typedef void (*spdk_delete_crypto_complete)(void *cb_arg, int bdeverrno);
3107fe6a43SSeth Howell 
3207fe6a43SSeth Howell /**
3307fe6a43SSeth Howell  * Create new crypto bdev.
3407fe6a43SSeth Howell  *
355ba9b78eSYuriy Umanets  * \param opts Crypto options populated by create_crypto_opts()
3607fe6a43SSeth Howell  * \return 0 on success, other on failure.
3707fe6a43SSeth Howell  */
385ba9b78eSYuriy Umanets int create_crypto_disk(struct vbdev_crypto_opts *opts);
3907fe6a43SSeth Howell 
4007fe6a43SSeth Howell /**
4107fe6a43SSeth Howell  * Delete crypto bdev.
4207fe6a43SSeth Howell  *
434573e4ccSShuhei Matsumoto  * \param bdev_name Crypto bdev name.
4407fe6a43SSeth Howell  * \param cb_fn Function to call after deletion.
4507fe6a43SSeth Howell  * \param cb_arg Argument to pass to cb_fn.
4607fe6a43SSeth Howell  */
474573e4ccSShuhei Matsumoto void delete_crypto_disk(const char *bdev_name, spdk_delete_crypto_complete cb_fn,
4807fe6a43SSeth Howell 			void *cb_arg);
4907fe6a43SSeth Howell 
505ba9b78eSYuriy Umanets /**
515ba9b78eSYuriy Umanets  * Release crypto opts created with create_crypto_opts()
525ba9b78eSYuriy Umanets  *
535ba9b78eSYuriy Umanets  * \param opts Crypto opts to release
545ba9b78eSYuriy Umanets  */
555ba9b78eSYuriy Umanets void free_crypto_opts(struct vbdev_crypto_opts *opts);
565ba9b78eSYuriy Umanets 
5707fe6a43SSeth Howell #endif /* SPDK_VBDEV_CRYPTO_H */
58