1 #ifndef _G_CCSL_NVOC_H_ 2 #define _G_CCSL_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 11 * SPDX-License-Identifier: MIT 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a 14 * copy of this software and associated documentation files (the "Software"), 15 * to deal in the Software without restriction, including without limitation 16 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 * and/or sell copies of the Software, and to permit persons to whom the 18 * Software is furnished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 * DEALINGS IN THE SOFTWARE. 30 */ 31 32 #include "g_ccsl_nvoc.h" 33 34 #ifndef CCSL_H 35 #define CCSL_H 36 37 #include "nvstatus.h" 38 #include "nvmisc.h" 39 #include "kernel/gpu/conf_compute/conf_compute.h" 40 #include "kernel/gpu/conf_compute/ccsl_context.h" 41 42 #define CCSL_DIR_HOST_TO_DEVICE 0 43 #define CCSL_DIR_DEVICE_TO_HOST 1 44 45 /****************************************************************************\ 46 * * 47 * CCSL module header. * 48 * * 49 ****************************************************************************/ 50 #ifdef NVOC_CCSL_H_PRIVATE_ACCESS_ALLOWED 51 #define PRIVATE_FIELD(x) x 52 #else 53 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 54 #endif 55 struct Ccsl { 56 const struct NVOC_RTTI *__nvoc_rtti; 57 struct Ccsl *__nvoc_pbase_Ccsl; 58 }; 59 60 #ifndef __NVOC_CLASS_Ccsl_TYPEDEF__ 61 #define __NVOC_CLASS_Ccsl_TYPEDEF__ 62 typedef struct Ccsl Ccsl; 63 #endif /* __NVOC_CLASS_Ccsl_TYPEDEF__ */ 64 65 #ifndef __nvoc_class_id_Ccsl 66 #define __nvoc_class_id_Ccsl 0x9bf1a1 67 #endif /* __nvoc_class_id_Ccsl */ 68 69 extern const struct NVOC_CLASS_DEF __nvoc_class_def_Ccsl; 70 71 #define __staticCast_Ccsl(pThis) \ 72 ((pThis)->__nvoc_pbase_Ccsl) 73 74 #ifdef __nvoc_ccsl_h_disabled 75 #define __dynamicCast_Ccsl(pThis) ((Ccsl*)NULL) 76 #else //__nvoc_ccsl_h_disabled 77 #define __dynamicCast_Ccsl(pThis) \ 78 ((Ccsl*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(Ccsl))) 79 #endif //__nvoc_ccsl_h_disabled 80 81 82 NV_STATUS __nvoc_objCreateDynamic_Ccsl(Ccsl**, Dynamic*, NvU32, va_list); 83 84 NV_STATUS __nvoc_objCreate_Ccsl(Ccsl**, Dynamic*, NvU32); 85 #define __objCreate_Ccsl(ppNewObj, pParent, createFlags) \ 86 __nvoc_objCreate_Ccsl((ppNewObj), staticCast((pParent), Dynamic), (createFlags)) 87 88 NV_STATUS ccslContextInitViaChannel_IMPL(pCcslContext *ppCtx, NvHandle hClient, NvHandle hChannel); 89 90 91 #define ccslContextInitViaChannel(ppCtx, hClient, hChannel) ccslContextInitViaChannel_IMPL(ppCtx, hClient, hChannel) 92 #define ccslContextInitViaChannel_HAL(ppCtx, hClient, hChannel) ccslContextInitViaChannel(ppCtx, hClient, hChannel) 93 94 NV_STATUS ccslContextInitViaKeyId_KERNEL(struct ConfidentialCompute *pConfCompute, pCcslContext *ppCtx, NvU32 globalKeyId); 95 96 97 #define ccslContextInitViaKeyId(pConfCompute, ppCtx, globalKeyId) ccslContextInitViaKeyId_KERNEL(pConfCompute, ppCtx, globalKeyId) 98 #define ccslContextInitViaKeyId_HAL(pConfCompute, ppCtx, globalKeyId) ccslContextInitViaKeyId(pConfCompute, ppCtx, globalKeyId) 99 100 NV_STATUS ccslRotateIv_IMPL(pCcslContext ctx, NvU8 direction); 101 102 103 #define ccslRotateIv(ctx, direction) ccslRotateIv_IMPL(ctx, direction) 104 #define ccslRotateIv_HAL(ctx, direction) ccslRotateIv(ctx, direction) 105 106 NV_STATUS ccslEncryptWithIv_IMPL(pCcslContext ctx, NvU32 bufferSize, const NvU8 *inputBuffer, NvU8 *encryptIv, const NvU8 *aadBuffer, NvU32 aadSize, NvU8 *outputBuffer, NvU8 *authTagBuffer); 107 108 109 #define ccslEncryptWithIv(ctx, bufferSize, inputBuffer, encryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslEncryptWithIv_IMPL(ctx, bufferSize, inputBuffer, encryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) 110 #define ccslEncryptWithIv_HAL(ctx, bufferSize, inputBuffer, encryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslEncryptWithIv(ctx, bufferSize, inputBuffer, encryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) 111 112 NV_STATUS ccslEncrypt_KERNEL(pCcslContext ctx, NvU32 bufferSize, const NvU8 *inputBuffer, const NvU8 *aadBuffer, NvU32 aadSize, NvU8 *outputBuffer, NvU8 *authTagBuffer); 113 114 115 #define ccslEncrypt(ctx, bufferSize, inputBuffer, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslEncrypt_KERNEL(ctx, bufferSize, inputBuffer, aadBuffer, aadSize, outputBuffer, authTagBuffer) 116 #define ccslEncrypt_HAL(ctx, bufferSize, inputBuffer, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslEncrypt(ctx, bufferSize, inputBuffer, aadBuffer, aadSize, outputBuffer, authTagBuffer) 117 118 NV_STATUS ccslDecrypt_KERNEL(pCcslContext ctx, NvU32 bufferSize, const NvU8 *inputBuffer, const NvU8 *decryptIv, const NvU8 *aadBuffer, NvU32 aadSize, NvU8 *outputBuffer, const NvU8 *authTagBuffer); 119 120 121 #define ccslDecrypt(ctx, bufferSize, inputBuffer, decryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslDecrypt_KERNEL(ctx, bufferSize, inputBuffer, decryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) 122 #define ccslDecrypt_HAL(ctx, bufferSize, inputBuffer, decryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) ccslDecrypt(ctx, bufferSize, inputBuffer, decryptIv, aadBuffer, aadSize, outputBuffer, authTagBuffer) 123 124 NV_STATUS ccslSign_IMPL(pCcslContext ctx, NvU32 bufferSize, const NvU8 *inputBuffer, NvU8 *authTagBuffer); 125 126 127 #define ccslSign(ctx, bufferSize, inputBuffer, authTagBuffer) ccslSign_IMPL(ctx, bufferSize, inputBuffer, authTagBuffer) 128 #define ccslSign_HAL(ctx, bufferSize, inputBuffer, authTagBuffer) ccslSign(ctx, bufferSize, inputBuffer, authTagBuffer) 129 130 NV_STATUS ccslQueryMessagePool_IMPL(pCcslContext ctx, NvU8 direction, NvU64 *messageNum); 131 132 133 #define ccslQueryMessagePool(ctx, direction, messageNum) ccslQueryMessagePool_IMPL(ctx, direction, messageNum) 134 #define ccslQueryMessagePool_HAL(ctx, direction, messageNum) ccslQueryMessagePool(ctx, direction, messageNum) 135 136 NV_STATUS ccslIncrementIv_IMPL(pCcslContext pCtx, NvU8 direction, NvU64 increment, NvU8 *iv); 137 138 139 #define ccslIncrementIv(pCtx, direction, increment, iv) ccslIncrementIv_IMPL(pCtx, direction, increment, iv) 140 #define ccslIncrementIv_HAL(pCtx, direction, increment, iv) ccslIncrementIv(pCtx, direction, increment, iv) 141 142 void ccslContextClear_IMPL(pCcslContext ctx); 143 144 #define ccslContextClear(ctx) ccslContextClear_IMPL(ctx) 145 NV_STATUS ccslIncrementCounter_IMPL(pCcslContext pCtx, NvU8 *ctr, NvU64 increment); 146 147 #define ccslIncrementCounter(pCtx, ctr, increment) ccslIncrementCounter_IMPL(pCtx, ctr, increment) 148 #undef PRIVATE_FIELD 149 150 #ifndef NVOC_CCSL_H_PRIVATE_ACCESS_ALLOWED 151 #undef ccslIncrementCounter 152 NV_STATUS NVOC_PRIVATE_FUNCTION(ccslIncrementCounter)(pCcslContext pCtx, NvU8 *ctr, NvU64 increment); 153 154 #endif // NVOC_CCSL_H_PRIVATE_ACCESS_ALLOWED 155 156 157 #endif // CCSL_H 158 159 #ifdef __cplusplus 160 } // extern "C" 161 #endif 162 163 #endif // _G_CCSL_NVOC_H_ 164