1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 /*! 25 * Provides the implementation for SPDM module that interacts between RM and SPDM. 26 */ 27 /* ------------------------------ Includes ---------------------------------- */ 28 #include "gpu/spdm/spdm.h" 29 #include "gpu/conf_compute/conf_compute.h" 30 #include "core/locks.h" 31 #include "ctrl/ctrl2080/ctrl2080spdm.h" 32 #include "rmapi/client_resource.h" 33 34 /* ------------------------- Macros and Defines ----------------------------- */ 35 36 /* ------------------------- Static Functions ------------------------------ */ 37 38 /* ------------------------- Public Functions ------------------------------ */ 39 40 /*! 41 * @brief spdmCtrlSpdmPartition 42 * Common function used to call gspCommandPostBlocking based on the platform on which it runs (i.e. vGPU, GSP-RM, Monolithic). 43 * 44 * @param[in] pGpu : OBJGPU Pointer 45 * @param[in] pSpdmPartitionParams : SPDM RPC structure pointer 46 */ 47 NV_STATUS spdmCtrlSpdmPartition 48 ( 49 OBJGPU *pGpu, 50 NV2080_CTRL_INTERNAL_SPDM_PARTITION_PARAMS *pSpdmPartitionParams 51 ) 52 { 53 NV_STATUS status = NV_OK; 54 55 LOCK_ASSERT_AND_RETURN(rmapiLockIsOwner() && rmGpuLockIsOwner()); 56 57 if (IS_VIRTUAL(pGpu)) 58 { 59 // The control call currently doesn't support the vGPU environment, therefore return NV_ERR_NOT_SUPPORTED. 60 return NV_ERR_NOT_SUPPORTED; 61 } 62 else if (IS_GSP_CLIENT(pGpu)) 63 { 64 RM_API *pRmApi = GPU_GET_PHYSICAL_RMAPI(pGpu); 65 66 // Calls the subdeviceCtrlCmdSpdmPartition_IMPL control call in Physical RM mode. 67 pRmApi->Control(pRmApi, 68 pGpu->hInternalClient, 69 pGpu->hInternalSubdevice, 70 NV2080_CTRL_INTERNAL_SPDM_PARTITION, 71 pSpdmPartitionParams, 72 sizeof(NV2080_CTRL_INTERNAL_SPDM_PARTITION_PARAMS)); 73 } 74 else 75 { 76 return NV_ERR_NOT_SUPPORTED; 77 } 78 79 return status; 80 } 81 82