github.com/sagernet/gvisor@v0.0.0-20240428053021-e691de28565f/pkg/abi/nvgpu/classes.go (about) 1 // Copyright 2023 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package nvgpu 16 17 import ( 18 "fmt" 19 ) 20 21 // ClassID is a client class ID, in the sense of 22 // src/nvidia/src/kernel/rmapi/resource_desc.h:RS_RESOURCE_DESC::externalClassID. 23 // 24 // +marshal 25 type ClassID uint32 26 27 // String implements fmt.Stringer.String. 28 func (id ClassID) String() string { 29 // Include leading zeroes for easier searchability, both here and in 30 // g_allclasses.h. 31 return fmt.Sprintf("0x%08x", uint32(id)) 32 } 33 34 // Class IDs, from src/nvidia/generated/g_allclasses.h. 35 const ( 36 NV01_ROOT = 0x00000000 37 NV01_ROOT_NON_PRIV = 0x00000001 38 NV01_MEMORY_SYSTEM = 0x0000003e 39 NV01_MEMORY_LOCAL_USER = 0x00000040 40 NV01_ROOT_CLIENT = 0x00000041 41 NV01_MEMORY_SYSTEM_OS_DESCRIPTOR = 0x00000071 42 NV01_EVENT_OS_EVENT = 0x00000079 43 NV01_DEVICE_0 = 0x00000080 44 NV_MEMORY_FABRIC = 0x000000f8 45 NV20_SUBDEVICE_0 = 0x00002080 46 NV2081_BINAPI = 0x00002081 47 NV50_P2P = 0x0000503b 48 NV50_THIRD_PARTY_P2P = 0x0000503c 49 NV50_MEMORY_VIRTUAL = 0x000050a0 50 GT200_DEBUGGER = 0x000083de 51 GF100_SUBDEVICE_MASTER = 0x000090e6 52 FERMI_CONTEXT_SHARE_A = 0x00009067 53 FERMI_VASPACE_A = 0x000090f1 54 KEPLER_CHANNEL_GROUP_A = 0x0000a06c 55 TURING_USERMODE_A = 0x0000c461 56 TURING_CHANNEL_GPFIFO_A = 0x0000c46f 57 AMPERE_CHANNEL_GPFIFO_A = 0x0000c56f 58 TURING_DMA_COPY_A = 0x0000c5b5 59 TURING_COMPUTE_A = 0x0000c5c0 60 HOPPER_USERMODE_A = 0x0000c661 61 AMPERE_DMA_COPY_A = 0x0000c6b5 62 AMPERE_COMPUTE_A = 0x0000c6c0 63 AMPERE_DMA_COPY_B = 0x0000c7b5 64 AMPERE_COMPUTE_B = 0x0000c7c0 65 HOPPER_CHANNEL_GPFIFO_A = 0x0000c86f 66 HOPPER_DMA_COPY_A = 0x0000c8b5 67 ADA_COMPUTE_A = 0x0000c9c0 68 NV_CONFIDENTIAL_COMPUTE = 0x0000cb33 69 HOPPER_SEC2_WORK_LAUNCH_A = 0x0000cba2 70 HOPPER_COMPUTE_A = 0x0000cbc0 71 ) 72 73 // NV2081_ALLOC_PARAMETERS is the alloc params type for NV2081_BINAPI, from 74 // src/common/sdk/nvidia/inc/class/cl2081.h. 75 // 76 // +marshal 77 type NV2081_ALLOC_PARAMETERS struct { 78 Reserved uint32 79 } 80 81 // NV0005_ALLOC_PARAMETERS is the alloc params type for NV01_EVENT_OS_EVENT, 82 // from src/common/sdk/nvidia/inc/class/cl0005.h. 83 // 84 // +marshal 85 type NV0005_ALLOC_PARAMETERS struct { 86 HParentClient Handle 87 HSrcResource Handle 88 HClass uint32 89 NotifyIndex uint32 90 Data P64 // actually FD for NV01_EVENT_OS_EVENT, see src/nvidia/src/kernel/rmapi/event.c:eventConstruct_IMPL() => src/nvidia/arch/nvalloc/unix/src/os.c:osUserHandleToKernelPtr() 91 } 92 93 // NV0080_ALLOC_PARAMETERS is the alloc params type for NV01_DEVICE_0, from 94 // src/common/sdk/nvidia/inc/class/cl0080.h. 95 // 96 // +marshal 97 type NV0080_ALLOC_PARAMETERS struct { 98 DeviceID uint32 99 HClientShare Handle 100 HTargetClient Handle 101 HTargetDevice Handle 102 Flags uint32 103 Pad0 [4]byte 104 VASpaceSize uint64 105 VAStartInternal uint64 106 VALimitInternal uint64 107 VAMode uint32 108 Pad1 [4]byte 109 } 110 111 // NV2080_ALLOC_PARAMETERS is the alloc params type for NV20_SUBDEVICE_0, from 112 // src/common/sdk/nvidia/inc/class/cl2080.h. 113 // 114 // +marshal 115 type NV2080_ALLOC_PARAMETERS struct { 116 SubDeviceID uint32 117 } 118 119 // NV_MEMORY_ALLOCATION_PARAMS is the alloc params type for various NV*_MEMORY* 120 // allocation classes, from src/common/sdk/nvidia/inc/nvos.h. 121 // 122 // +marshal 123 type NV_MEMORY_ALLOCATION_PARAMS struct { 124 Owner uint32 125 Type uint32 126 Flags uint32 127 Width uint32 128 Height uint32 129 Pitch int32 130 Attr uint32 131 Attr2 uint32 132 Format uint32 133 ComprCovg uint32 134 ZcullCovg uint32 135 _ uint32 136 RangeLo uint64 137 RangeHi uint64 138 Size uint64 139 Alignment uint64 140 Offset uint64 141 Limit uint64 142 Address P64 143 CtagOffset uint32 144 HVASpace Handle 145 InternalFlags uint32 146 Tag uint32 147 } 148 149 // NV_MEMORY_ALLOCATION_PARAMS_V545 is the updated version of 150 // NV_MEMORY_ALLOCATION_PARAMS since 545.23.06. 151 // 152 // +marshal 153 type NV_MEMORY_ALLOCATION_PARAMS_V545 struct { 154 NV_MEMORY_ALLOCATION_PARAMS 155 NumaNode int32 156 _ uint32 157 } 158 159 // NV503B_BAR1_P2P_DMA_INFO from src/common/sdk/nvidia/inc/class/cl503b.h. 160 // 161 // +marshal 162 type NV503B_BAR1_P2P_DMA_INFO struct { 163 DmaAddress uint64 164 DmaSize uint64 165 } 166 167 // NV503B_ALLOC_PARAMETERS is the alloc params type for NV50_P2P, from 168 // src/common/sdk/nvidia/inc/class/cl503b.h. 169 // 170 // +marshal 171 type NV503B_ALLOC_PARAMETERS struct { 172 HSubDevice Handle 173 HPeerSubDevice Handle 174 SubDevicePeerIDMask uint32 175 PeerSubDevicePeerIDMask uint32 176 MailboxBar1Addr uint64 177 MailboxTotalSize uint32 178 Flags uint32 179 SubDeviceEgmPeerIDMask uint32 180 PeerSubDeviceEgmPeerIDMask uint32 181 L2pBar1P2PDmaInfo NV503B_BAR1_P2P_DMA_INFO 182 P2lBar1P2PDmaInfo NV503B_BAR1_P2P_DMA_INFO 183 } 184 185 // NV503C_ALLOC_PARAMETERS is the alloc params type for NV50_THIRD_PARTY_P2P, 186 // from src/common/sdk/nvidia/inc/class/cl503c.h. 187 // 188 // +marshal 189 type NV503C_ALLOC_PARAMETERS struct { 190 Flags uint32 191 } 192 193 // NV83DE_ALLOC_PARAMETERS is the alloc params type for GT200_DEBUGGER, 194 // from src/common/sdk/nvidia/inc/class/cl83de.h. 195 // 196 // +marshal 197 type NV83DE_ALLOC_PARAMETERS struct { 198 HDebuggerClient_Obsolete Handle 199 HAppClient Handle 200 HClass3DObject Handle 201 } 202 203 // NV_CTXSHARE_ALLOCATION_PARAMETERS is the alloc params type for 204 // FERMI_CONTEXT_SHARE_A, from src/common/sdk/nvidia/inc/nvos.h. 205 // 206 // +marshal 207 type NV_CTXSHARE_ALLOCATION_PARAMETERS struct { 208 HVASpace Handle 209 Flags uint32 210 SubctxID uint32 211 } 212 213 // NV_VASPACE_ALLOCATION_PARAMETERS is the alloc params type for 214 // FERMI_VASPACE_A, from src/common/sdk/nvidia/inc/nvos.h. 215 // 216 // +marshal 217 type NV_VASPACE_ALLOCATION_PARAMETERS struct { 218 Index uint32 219 Flags uint32 220 VASize uint64 221 VAStartInternal uint64 222 VALimitInternal uint64 223 BigPageSize uint32 224 Pad0 [4]byte 225 VABase uint64 226 } 227 228 // NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS is the alloc params type for 229 // KEPLER_CHANNEL_GROUP_A, from src/common/sdk/nvidia/inc/nvos.h. 230 // 231 // +marshal 232 type NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS struct { 233 HObjectError Handle 234 HObjectECCError Handle 235 HVASpace Handle 236 EngineType uint32 237 BIsCallingContextVgpuPlugin uint8 238 Pad0 [3]byte 239 } 240 241 // NV_MEMORY_DESC_PARAMS is from 242 // src/common/sdk/nvidia/inc/alloc/alloc_channel.h. 243 // 244 // +marshal 245 type NV_MEMORY_DESC_PARAMS struct { 246 Base uint64 247 Size uint64 248 AddressSpace uint32 249 CacheAttrib uint32 250 } 251 252 // NV_CHANNEL_ALLOC_PARAMS is the alloc params type for TURING_CHANNEL_GPFIFO_A 253 // and AMPERE_CHANNEL_GPFIFO_A, from 254 // src/common/sdk/nvidia/inc/alloc/alloc_channel.h. 255 // 256 // +marshal 257 type NV_CHANNEL_ALLOC_PARAMS struct { 258 HObjectError Handle 259 HObjectBuffer Handle 260 GPFIFOOffset uint64 261 GPFIFOEntries uint32 262 Flags uint32 263 HContextShare Handle 264 HVASpace Handle 265 HUserdMemory [NV_MAX_SUBDEVICES]Handle 266 UserdOffset [NV_MAX_SUBDEVICES]uint64 267 EngineType uint32 268 CID uint32 269 SubDeviceID uint32 270 HObjectECCError Handle 271 InstanceMem NV_MEMORY_DESC_PARAMS 272 UserdMem NV_MEMORY_DESC_PARAMS 273 RamfcMem NV_MEMORY_DESC_PARAMS 274 MthdbufMem NV_MEMORY_DESC_PARAMS 275 HPhysChannelGroup Handle 276 InternalFlags uint32 277 ErrorNotifierMem NV_MEMORY_DESC_PARAMS 278 ECCErrorNotifierMem NV_MEMORY_DESC_PARAMS 279 ProcessID uint32 280 SubProcessID uint32 281 EncryptIv [CC_CHAN_ALLOC_IV_SIZE_DWORD]uint32 282 DecryptIv [CC_CHAN_ALLOC_IV_SIZE_DWORD]uint32 283 HmacNonce [CC_CHAN_ALLOC_NONCE_SIZE_DWORD]uint32 284 } 285 286 // NVB0B5_ALLOCATION_PARAMETERS is the alloc param type for TURING_DMA_COPY_A, 287 // AMPERE_DMA_COPY_A, and AMPERE_DMA_COPY_B from 288 // src/common/sdk/nvidia/inc/class/clb0b5sw.h. 289 // 290 // +marshal 291 type NVB0B5_ALLOCATION_PARAMETERS struct { 292 Version uint32 293 EngineType uint32 294 } 295 296 // NV_GR_ALLOCATION_PARAMETERS is the alloc param type for TURING_COMPUTE_A, 297 // AMPERE_COMPUTE_A, and ADA_COMPUTE_A, from src/common/sdk/nvidia/inc/nvos.h. 298 // 299 // +marshal 300 type NV_GR_ALLOCATION_PARAMETERS struct { 301 Version uint32 302 Flags uint32 303 Size uint32 304 Caps uint32 305 } 306 307 // NV_HOPPER_USERMODE_A_PARAMS is the alloc param type for HOPPER_USERMODE_A, 308 // from src/common/sdk/nvidia/inc/nvos.h. 309 // 310 // +marshal 311 type NV_HOPPER_USERMODE_A_PARAMS struct { 312 Bar1Mapping uint8 313 Priv uint8 314 } 315 316 // +marshal 317 type nv00f8Map struct { 318 offset uint64 319 hVidMem Handle 320 flags uint32 321 } 322 323 // NV00F8_ALLOCATION_PARAMETERS is the alloc param type for NV_MEMORY_FABRIC, 324 // from src/common/sdk/nvidia/inc/class/cl00f8.h. 325 // 326 // +marshal 327 type NV00F8_ALLOCATION_PARAMETERS struct { 328 Alignment uint64 329 AllocSize uint64 330 PageSize uint64 331 AllocFlags uint32 332 _ uint32 333 Map nv00f8Map 334 } 335 336 // NV_CONFIDENTIAL_COMPUTE_ALLOC_PARAMS is the alloc param type for 337 // NV_CONFIDENTIAL_COMPUTE, from src/common/sdk/nvidia/inc/class/clcb33.h. 338 // 339 // +marshal 340 type NV_CONFIDENTIAL_COMPUTE_ALLOC_PARAMS struct { 341 Handle Handle 342 _ uint32 343 }