107fe6a43SSeth Howell /*- 207fe6a43SSeth Howell * BSD LICENSE 307fe6a43SSeth Howell * 407fe6a43SSeth Howell * Copyright (c) Intel Corporation. 507fe6a43SSeth Howell * All rights reserved. 607fe6a43SSeth Howell * 707fe6a43SSeth Howell * Redistribution and use in source and binary forms, with or without 807fe6a43SSeth Howell * modification, are permitted provided that the following conditions 907fe6a43SSeth Howell * are met: 1007fe6a43SSeth Howell * 1107fe6a43SSeth Howell * * Redistributions of source code must retain the above copyright 1207fe6a43SSeth Howell * notice, this list of conditions and the following disclaimer. 1307fe6a43SSeth Howell * * Redistributions in binary form must reproduce the above copyright 1407fe6a43SSeth Howell * notice, this list of conditions and the following disclaimer in 1507fe6a43SSeth Howell * the documentation and/or other materials provided with the 1607fe6a43SSeth Howell * distribution. 1707fe6a43SSeth Howell * * Neither the name of Intel Corporation nor the names of its 1807fe6a43SSeth Howell * contributors may be used to endorse or promote products derived 1907fe6a43SSeth Howell * from this software without specific prior written permission. 2007fe6a43SSeth Howell * 2107fe6a43SSeth Howell * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2207fe6a43SSeth Howell * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2307fe6a43SSeth Howell * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2407fe6a43SSeth Howell * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2507fe6a43SSeth Howell * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2607fe6a43SSeth Howell * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2707fe6a43SSeth Howell * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2807fe6a43SSeth Howell * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2907fe6a43SSeth Howell * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3007fe6a43SSeth Howell * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3107fe6a43SSeth Howell * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3207fe6a43SSeth Howell */ 3307fe6a43SSeth Howell 3407fe6a43SSeth Howell #ifndef SPDK_VBDEV_CRYPTO_H 3507fe6a43SSeth Howell #define SPDK_VBDEV_CRYPTO_H 3607fe6a43SSeth Howell 3707fe6a43SSeth Howell #include "spdk/rpc.h" 3807fe6a43SSeth Howell #include "spdk/util.h" 3907fe6a43SSeth Howell #include "spdk/string.h" 40*4e8e97c8STomasz Zawadzki #include "spdk/log.h" 4107fe6a43SSeth Howell 4207fe6a43SSeth Howell #include "spdk/bdev.h" 4307fe6a43SSeth Howell 44593cb5b3Spaul luse #define AESNI_MB "crypto_aesni_mb" 45593cb5b3Spaul luse #define QAT "crypto_qat" 46593cb5b3Spaul luse 47f070b78cSpaul luse /* Supported ciphers */ 48f070b78cSpaul luse #define AES_CBC "AES_CBC" /* QAT and AESNI_MB */ 49f070b78cSpaul luse #define AES_XTS "AES_XTS" /* QAT only */ 50f070b78cSpaul luse 5107fe6a43SSeth Howell typedef void (*spdk_delete_crypto_complete)(void *cb_arg, int bdeverrno); 5207fe6a43SSeth Howell 5307fe6a43SSeth Howell /** 5407fe6a43SSeth Howell * Create new crypto bdev. 5507fe6a43SSeth Howell * 561880df4dSpaul luse * \param bdev_name Name of the bdev on which the crypto vbdev will be created. 571880df4dSpaul luse * \param vbdev_name Name of the new crypto vbdev. 581880df4dSpaul luse * \param crypto_pmd Name of the polled mode driver to use for this vbdev. 591880df4dSpaul luse * \param key The key to use for this vbdev. 60f070b78cSpaul luse * \param cipher The cipher to use for this vbdev. 61f070b78cSpaul luse * \param keys The 2nd key to use for AES_XTS cipher. 6207fe6a43SSeth Howell * \return 0 on success, other on failure. 6307fe6a43SSeth Howell */ 6407fe6a43SSeth Howell int create_crypto_disk(const char *bdev_name, const char *vbdev_name, 65f070b78cSpaul luse const char *crypto_pmd, const char *key, 66f070b78cSpaul luse const char *cipher, const char *key2); 6707fe6a43SSeth Howell 6807fe6a43SSeth Howell /** 6907fe6a43SSeth Howell * Delete crypto bdev. 7007fe6a43SSeth Howell * 7107fe6a43SSeth Howell * \param bdev Pointer to crypto bdev. 7207fe6a43SSeth Howell * \param cb_fn Function to call after deletion. 7307fe6a43SSeth Howell * \param cb_arg Argument to pass to cb_fn. 7407fe6a43SSeth Howell */ 7507fe6a43SSeth Howell void delete_crypto_disk(struct spdk_bdev *bdev, spdk_delete_crypto_complete cb_fn, 7607fe6a43SSeth Howell void *cb_arg); 7707fe6a43SSeth Howell 7807fe6a43SSeth Howell #endif /* SPDK_VBDEV_CRYPTO_H */ 79