1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2018 Intel Corporation. 3 * All rights reserved. 4 * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. 5 * All rights reserved. 6 */ 7 8 #ifndef SPDK_VBDEV_CRYPTO_H 9 #define SPDK_VBDEV_CRYPTO_H 10 11 #include "spdk/rpc.h" 12 #include "spdk/util.h" 13 #include "spdk/string.h" 14 #include "spdk/log.h" 15 #include "spdk/accel.h" 16 #include "spdk/accel_module.h" 17 18 #include "spdk/bdev.h" 19 20 #define BDEV_CRYPTO_DEFAULT_CIPHER "AES_CBC" /* QAT and AESNI_MB */ 21 22 /* Structure to hold crypto options */ 23 struct vbdev_crypto_opts { 24 char *vbdev_name; /* name of the vbdev to create */ 25 char *bdev_name; /* base bdev name */ 26 struct spdk_accel_crypto_key *key; /* crypto key */ 27 bool key_owner; /* If wet to true then the key was created by RPC and needs to be destroyed */ 28 }; 29 30 typedef void (*spdk_delete_crypto_complete)(void *cb_arg, int bdeverrno); 31 32 /** 33 * Create new crypto bdev. 34 * 35 * \param opts Crypto options populated by create_crypto_opts() 36 * \return 0 on success, other on failure. 37 */ 38 int create_crypto_disk(struct vbdev_crypto_opts *opts); 39 40 /** 41 * Delete crypto bdev. 42 * 43 * \param bdev_name Crypto bdev name. 44 * \param cb_fn Function to call after deletion. 45 * \param cb_arg Argument to pass to cb_fn. 46 */ 47 void delete_crypto_disk(const char *bdev_name, spdk_delete_crypto_complete cb_fn, 48 void *cb_arg); 49 50 /** 51 * Release crypto opts created with create_crypto_opts() 52 * 53 * \param opts Crypto opts to release 54 */ 55 void free_crypto_opts(struct vbdev_crypto_opts *opts); 56 57 #endif /* SPDK_VBDEV_CRYPTO_H */ 58