1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2012-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 #include "ctrl/ctrla081.h" 25 #include "class/clc637.h" // for AMPERE_SMC_PARTITION_REF 26 #include "virtualization/kernel_hostvgpudeviceapi.h" 27 28 // 29 // ODB functions 30 // 31 32 NV_STATUS 33 kvgpumgrConstruct_IMPL(KernelVgpuMgr *pKernelVgpuMgr) 34 { 35 return NV_OK; 36 } 37 38 void 39 kvgpumgrDestruct_IMPL(KernelVgpuMgr *pKernelVgpuMgr) 40 { 41 } 42 43 // 44 // Get max instance for a vgpu profile. 45 // 46 NV_STATUS 47 kvgpumgrGetMaxInstanceOfVgpu(NvU32 vgpuTypeId, NvU32 *maxInstanceVgpu) 48 { 49 return NV_ERR_NOT_SUPPORTED; 50 } 51 52 NV_STATUS 53 kvgpumgrGetPgpuIndex(KernelVgpuMgr *pKernelVgpuMgr, NvU32 gpuPciId, NvU32* index) 54 { 55 return NV_ERR_OBJECT_NOT_FOUND; 56 } 57 58 NvBool 59 kvgpumgrIsHeterogeneousVgpuSupported(void) 60 { 61 return NV_FALSE; 62 } 63 64 NV_STATUS 65 kvgpumgrCheckVgpuTypeCreatable(KERNEL_PHYS_GPU_INFO *pPhysGpuInfo, VGPU_TYPE *vgpuTypeInfo) 66 { 67 return NV_ERR_NOT_SUPPORTED; 68 } 69 70 NV_STATUS 71 kvgpumgrGetCreatableVgpuTypes(OBJGPU *pGpu, KernelVgpuMgr *pKernelVgpuMgr, NvU32 pgpuIndex, NvU32* numVgpuTypes, NvU32* vgpuTypes) 72 { 73 return NV_ERR_NOT_SUPPORTED; 74 } 75 76 NV_STATUS 77 kvgpumgrGetVgpuTypeInfo(NvU32 vgpuTypeId, VGPU_TYPE **vgpuType) 78 { 79 return NV_ERR_OBJECT_NOT_FOUND; 80 } 81 82 NV_STATUS 83 kvgpumgrSendAllVgpuTypesToGsp(OBJGPU *pGpu) 84 { 85 return NV_ERR_NOT_SUPPORTED; 86 } 87 88 NV_STATUS 89 kvgpumgrPgpuAddVgpuType 90 ( 91 OBJGPU *pGpu, 92 NvBool discardVgpuTypes, 93 NVA081_CTRL_VGPU_INFO *pVgpuInfo 94 ) 95 { 96 return NV_ERR_NOT_SUPPORTED; 97 } 98 99 NV_STATUS 100 kvgpumgrAttachGpu(NvU32 gpuPciId) 101 { 102 return NV_OK; 103 } 104 105 NV_STATUS 106 kvgpumgrDetachGpu(NvU32 gpuPciId) 107 { 108 return NV_OK; 109 } 110 111 /* 112 * @brief Sets Guest(VM) ID for the requested hostvgpudevice 113 * 114 * @param pParams SET_GUEST_ID_PARAMS Pointer 115 * @param pKernelHostVgpuDevice Device for which Vm ID need to be set 116 * @param pGpu OBJGPU pointer 117 * 118 * @return NV_STATUS 119 */ 120 NV_STATUS 121 kvgpumgrRegisterGuestId(SET_GUEST_ID_PARAMS *pParams, 122 KERNEL_HOST_VGPU_DEVICE *pKernelHostVgpuDevice, OBJGPU *pGpu) 123 { 124 return NV_ERR_NOT_SUPPORTED; 125 } 126 127 NV_STATUS 128 kvgpumgrGuestRegister(OBJGPU *pGpu, 129 NvU32 gfid, 130 NvU32 vgpuType, 131 NvU32 vmPid, 132 VM_ID_TYPE vmIdType, 133 VM_ID guestVmId, 134 NvHandle hPluginFBAllocationClient, 135 NvU32 numChannels, 136 NvU32 numPluginChannels, 137 NvU32 swizzId, 138 NvU32 vgpuDeviceInstanceId, 139 NvBool bDisableDefaultSmcExecPartRestore, 140 KERNEL_HOST_VGPU_DEVICE **ppKernelHostVgpuDevice) 141 { 142 return NV_ERR_NOT_SUPPORTED; 143 } 144 145 NV_STATUS 146 kvgpumgrGuestUnregister(OBJGPU *pGpu, KERNEL_HOST_VGPU_DEVICE *pKernelHostVgpuDevice) 147 { 148 return NV_ERR_NOT_SUPPORTED; 149 } 150 151 // 152 // Helper function to check if pGPU is live migration capable. 153 // 154 NvBool 155 kvgpumgrCheckPgpuMigrationSupport(OBJGPU *pGpu) 156 { 157 return NV_FALSE; 158 } 159 160 NvU32 kvgpumgrGetPgpuDevIdEncoding(OBJGPU *pGpu, NvU8 *pgpuString, 161 NvU32 strSize) 162 { 163 return NV_U32_MAX; 164 } 165 166 NvU32 kvgpumgrGetPgpuSubdevIdEncoding(OBJGPU *pGpu, NvU8 *pgpuString, 167 NvU32 strSize) 168 { 169 return NV_U32_MAX; 170 } 171 172 NvU32 kvgpumgrGetPgpuFSEncoding(OBJGPU *pGpu, NvU8 *pgpuString, 173 NvU32 strSize) 174 { 175 return NV_U32_MAX; 176 } 177 178 // 179 // A 32-bit variable is used to consolidate various GPU capabilities like 180 // ECC, SRIOV etc. The function sets the capabilities in the variable and 181 // converted to an ascii-encoded format. 182 // 183 NvU32 kvgpumgrGetPgpuCapEncoding(OBJGPU *pGpu, NvU8 *pgpuString, NvU32 strSize) 184 { 185 return NV_U32_MAX; 186 } 187 188 /* 189 * Get the user provide vGPU version range 190 */ 191 NV_STATUS 192 kvgpumgrGetHostVgpuVersion(NvU32 *user_min_supported_version, 193 NvU32 *user_max_supported_version) 194 { 195 return NV_ERR_NOT_SUPPORTED; 196 } 197 198 /* 199 * Set the user provide vGPU version range 200 */ 201 NV_STATUS 202 kvgpumgrSetHostVgpuVersion(NvU32 user_min_supported_version, 203 NvU32 user_max_supported_version) 204 { 205 return NV_ERR_NOT_SUPPORTED; 206 } 207 208 NV_STATUS 209 kvgpumgrGetSwizzId(OBJGPU *pGpu, 210 KERNEL_PHYS_GPU_INFO *pPhysGpuInfo, 211 NvU32 partitionFlag, 212 NvU32 *swizzId) 213 { 214 return NV_ERR_NOT_SUPPORTED; 215 } 216 217 NV_STATUS 218 kvgpumgrValidateSwizzId(OBJGPU *pGpu, 219 NvU32 vgpuTypeId, 220 NvU32 swizzId) 221 { 222 return NV_ERR_NOT_SUPPORTED; 223 } 224 225 NV_STATUS 226 kvgpumgrGetPartitionFlag(NvU32 vgpuTypeId, NvU32 *partitionFlag) 227 { 228 return NV_ERR_INVALID_ARGUMENT; 229 } 230 231 /* 232 * Add or remove VF info to pgpuInfo of its PF 233 * @param[in] gpuPciId PCI ID of target PF 234 * @param[in] cmd 235 * 0/VGPU_CMD_PROCESS_VF_INFO.NV_VGPU_SAVE_VF_INFO = Add VF info to VF list of target PF 236 * 1/VGPU_CMD_PROCESS_VF_INFO.NV_VGPU_REMOVE_VF_INFO = Remove VF info from VF list of target PF 237 * @param[in] domain Domain of VF to be stored 238 * @param[in] bus Bus no. of VF to be stored 239 * @param[in] slot Slot no. of VF to be stored 240 * @param[in] function Function of VF to be stored 241 * @param[in] isMdevAttached Flag to indicate if VF is registered with mdev 242 * @param[out]vfPciInfo Array of PCI information of VFs 243 */ 244 NV_STATUS 245 kvgpumgrProcessVfInfo(NvU32 gpuPciId, NvU8 cmd, NvU32 domain, NvU32 bus, NvU32 slot, NvU32 function, NvBool isMdevAttached, vgpu_vf_pci_info *vfPciInfo) 246 { 247 return NV_ERR_NOT_SUPPORTED; 248 } 249 250 NV_STATUS 251 kvgpumgrEnumerateVgpuPerPgpu(OBJGPU *pGpu, NV2080_CTRL_VGPU_MGR_INTERNAL_ENUMERATE_VGPU_PER_PGPU_PARAMS *pParams) 252 { 253 return NV_ERR_NOT_SUPPORTED; 254 } 255 256 NV_STATUS 257 kvgpumgrClearGuestVmInfo(OBJGPU *pGpu, KERNEL_HOST_VGPU_DEVICE *pKernelHostVgpuDevice) 258 { 259 return NV_ERR_NOT_SUPPORTED; 260 } 261 262 NV_STATUS 263 kvgpumgrGetVgpuFbUsage(OBJGPU *pGpu, NVA081_CTRL_VGPU_CONFIG_GET_VGPU_FB_USAGE_PARAMS *pParams) 264 { 265 return NV_ERR_NOT_SUPPORTED; 266 } 267 268 NV_STATUS 269 kvgpumgrSetVgpuEncoderCapacity(OBJGPU *pGpu, NvU8 *vgpuUuid, NvU32 encoderCapacity) 270 { 271 return NV_ERR_NOT_SUPPORTED; 272 } 273 274 NV_STATUS 275 kvgpumgrStart(const NvU8 *pMdevUuid, void *waitQueue, NvS32 *returnStatus, 276 NvU8 *vmName, NvU32 qemuPid) 277 { 278 return NV_ERR_OBJECT_NOT_FOUND; 279 } 280 281 // 282 // Add vGPU info received on mdev_create sysfs call to REQUEST_VGPU_INFO_NODE 283 // list. REQUEST_VGPU_INFO_NODE is currently used only for vGPU on KVM. 284 // 285 // This funtion first checks whether the vGPU type is supported or not as 286 // only homegeneous vGPU types are supported currently. Also, this function 287 // only creates REQUEST_VGPU_INFO_NODE entry, actual vGPU will be created later 288 // 289 NV_STATUS 290 kvgpumgrCreateRequestVgpu(NvU32 gpuPciId, const NvU8 *pMdevUuid, 291 NvU32 vgpuTypeId, NvU16 *vgpuId, NvU32 gpuPciBdf) 292 { 293 return NV_ERR_NOT_SUPPORTED; 294 } 295 296 // 297 // Delete REQUEST_VGPU_INFO_NODE structure from list. 298 // REQUEST_VGPU_INFO_NODE is currently used only for vGPU on KVM. 299 // 300 NV_STATUS 301 kvgpumgrDeleteRequestVgpu(const NvU8 *pMdevUuid, NvU16 vgpuId) 302 { 303 return NV_ERR_OBJECT_NOT_FOUND; 304 } 305 306 NV_STATUS 307 kvgpumgrGetHostVgpuDeviceFromMdevUuid(NvU32 gpuPciId, const NvU8 *pMdevUuid, 308 KERNEL_HOST_VGPU_DEVICE **ppKernelHostVgpuDevice) 309 { 310 return NV_ERR_OBJECT_NOT_FOUND; 311 } 312 313 NV_STATUS 314 kvgpumgrGetHostVgpuDeviceFromVgpuUuid(NvU32 gpuPciId, NvU8 *vgpuUuid, 315 KERNEL_HOST_VGPU_DEVICE **ppKernelHostVgpuDevice) 316 { 317 return NV_ERR_NOT_SUPPORTED; 318 } 319 320 NV_STATUS 321 kvgpumgrGetConfigEventInfoFromDb(NvHandle hClient, 322 NvHandle hVgpuConfig, 323 VGPU_CONFIG_EVENT_INFO_NODE **ppVgpuConfigEventInfoNode, 324 NvU32 pgpuIndex) 325 { 326 return NV_ERR_OBJECT_NOT_FOUND; 327 } 328 329 NV_STATUS 330 kvgpuMgrRestoreSmcExecPart 331 ( 332 OBJGPU *pGpu, 333 KERNEL_HOST_VGPU_DEVICE *pKernelHostVgpuDevice, 334 KERNEL_MIG_GPU_INSTANCE *pKernelMIGGpuInstance 335 ) 336 { 337 return NV_ERR_NOT_SUPPORTED; 338 } 339