1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2009-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 #pragma once 25 26 #include <nvtypes.h> 27 28 // 29 // This file was generated with FINN, an NVIDIA coding tool. 30 // Source file: ctrl/ctrl0000/ctrl0000unix.finn 31 // 32 33 #include "ctrl/ctrl0000/ctrl0000base.h" 34 35 #include "ctrl/ctrlxxxx.h" 36 /* NV01_ROOT (client) Linux control commands and parameters */ 37 38 /* 39 * NV0000_CTRL_CMD_OS_UNIX_FLUSH_USER_CACHE 40 * 41 * This command may be used to force a cache flush for a range of virtual addresses in 42 * memory. Can be used for either user or kernel addresses. 43 * 44 * offset, length 45 * These parameters specify the offset within the memory block 46 * and the number of bytes to flush/invalidate 47 * cacheOps 48 * This parameter flags whether to flush, invalidate or do both. 49 * Possible values are: 50 * NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_FLUSH 51 * NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_INVALIDATE 52 * NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_FLUSH_INVALIDATE 53 * hDevice 54 * This parameter is the handle to the device 55 * hObject 56 * This parameter is the handle to the memory structure being operated on. 57 * internalOnly 58 * Intended for internal use unless client is running in MODS UNIX environment, 59 * in which case this parameter specify the virtual address of the memory block 60 * to flush. 61 * 62 * Possible status values are: 63 * NV_OK 64 * NV_ERR_OBJECT_NOT_FOUND 65 * NV_ERR_INVALID_OBJECT_HANDLE 66 * NV_ERR_INVALID_COMMAND 67 * NV_ERR_INVALID_LIMIT 68 * NV_ERR_NOT_SUPPORTED 69 */ 70 #define NV0000_CTRL_CMD_OS_UNIX_FLUSH_USER_CACHE (0x3d02) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_FLUSH_USER_CACHE_PARAMS_MESSAGE_ID" */ 71 72 #define NV0000_CTRL_OS_UNIX_FLUSH_USER_CACHE_PARAMS_MESSAGE_ID (0x2U) 73 74 typedef struct NV0000_CTRL_OS_UNIX_FLUSH_USER_CACHE_PARAMS { 75 NV_DECLARE_ALIGNED(NvU64 offset, 8); 76 NV_DECLARE_ALIGNED(NvU64 length, 8); 77 NvU32 cacheOps; 78 NvHandle hDevice; 79 NvHandle hObject; 80 NV_DECLARE_ALIGNED(NvU64 internalOnly, 8); 81 } NV0000_CTRL_OS_UNIX_FLUSH_USER_CACHE_PARAMS; 82 83 #define NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_FLUSH (0x00000001) 84 #define NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_INVALIDATE (0x00000002) 85 #define NV0000_CTRL_OS_UNIX_FLAGS_USER_CACHE_FLUSH_INVALIDATE (0x00000003) 86 87 88 /* 89 * NV0000_CTRL_CMD_OS_UNIX_GET_CONTROL_FILE_DESCRIPTOR 90 * 91 * This command is used to get the control file descriptor. 92 * 93 * Possible status values returned are: 94 * NV_OK 95 * 96 */ 97 #define NV0000_CTRL_CMD_OS_UNIX_GET_CONTROL_FILE_DESCRIPTOR (0x3d04) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | 0x4" */ 98 99 typedef struct NV0000_CTRL_OS_UNIX_GET_CONTROL_FILE_DESCRIPTOR_PARAMS { 100 NvS32 fd; 101 } NV0000_CTRL_OS_UNIX_GET_CONTROL_FILE_DESCRIPTOR_PARAMS; 102 103 typedef enum NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE { 104 NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE_NONE = 0, 105 NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE_RM = 1, 106 } NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE; 107 108 typedef struct NV0000_CTRL_OS_UNIX_EXPORT_OBJECT { 109 NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE type; 110 111 union { 112 struct { 113 NvHandle hDevice; 114 NvHandle hParent; 115 NvHandle hObject; 116 } rmObject; 117 } data; 118 } NV0000_CTRL_OS_UNIX_EXPORT_OBJECT; 119 120 /* 121 * NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD 122 * 123 * This command may be used to export NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE 124 * object to file descriptor. 125 * 126 * Note that the 'fd' parameter is an input parameter at the kernel level, but 127 * an output parameter for usermode RMAPI clients -- the RMAPI library will 128 * open a new FD automatically if a usermode RMAPI client exports an object. 129 * 130 * Kernel-mode RM clients can export an object to an FD in two steps: 131 * 1. User client calls this RMControl with the flag 'EMPTY_FD_TRUE' to create 132 * an empty FD to receive the object, then passes that FD to the kernel-mode 133 * RM client. 134 * 2. Kernel-mode RM client fills in the rest of the 135 * NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS as usual and calls RM to 136 * associate its desired RM object with the empty FD from its usermode 137 * client. 138 * 139 * Possible status values returned are: 140 * NV_OK 141 * NV_ERR_NOT_SUPPORTED 142 * NV_ERR_OBJECT_NOT_FOUND 143 * NV_ERR_INVALID_OBJECT_HANDLE 144 * NV_ERR_INVALID_PARAMETER 145 */ 146 #define NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD (0x3d05) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS_MESSAGE_ID" */ 147 148 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS_MESSAGE_ID (0x5U) 149 150 typedef struct NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS { 151 NV0000_CTRL_OS_UNIX_EXPORT_OBJECT object; /* IN */ 152 NvS32 fd; /* IN/OUT */ 153 NvU32 flags; /* IN */ 154 } NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS; 155 156 /* 157 * If EMPTY_FD is TRUE, the 'fd' will be created but no object will be 158 * associated with it. The hDevice parameter is still required, to determine 159 * the correct device node on which to create the file descriptor. 160 * (An empty FD can then be passed to a kernel-mode driver to associate it with 161 * an actual object.) 162 */ 163 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_FLAGS_EMPTY_FD 0:0 164 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_FLAGS_EMPTY_FD_FALSE (0x00000000) 165 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_FLAGS_EMPTY_FD_TRUE (0x00000001) 166 167 /* 168 * NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD 169 * 170 * This command may be used to import back 171 * NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE object from file descriptor. 172 * 173 * Possible status values returned are: 174 * NV_OK 175 * NV_ERR_NOT_SUPPORTED 176 * NV_ERR_OBJECT_NOT_FOUND 177 * NV_ERR_INVALID_OBJECT_HANDLE 178 * NV_ERR_INVALID_PARAMETER 179 */ 180 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD (0x3d06) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS_MESSAGE_ID" */ 181 182 #define NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS_MESSAGE_ID (0x6U) 183 184 typedef struct NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS { 185 NvS32 fd; /* IN */ 186 NV0000_CTRL_OS_UNIX_EXPORT_OBJECT object; /* IN */ 187 } NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS; 188 189 /* 190 * NV0000_CTRL_CMD_OS_GET_GPU_INFO 191 * 192 * This command will query the OS specific info for the specified GPU. 193 * 194 * gpuId 195 * This parameter should specify a valid GPU ID value. If there 196 * is no GPU present with the specified ID, a status of 197 * NV_ERR_INVALID_ARGUMENT is returned. 198 * minorNum 199 * This parameter returns minor number of device node. 200 * 201 * Possible status values returned are: 202 * NV_OK 203 * NV_ERR_INVALID_ARGUMENT 204 */ 205 206 #define NV0000_CTRL_CMD_OS_GET_GPU_INFO (0x3d07) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | 0x7" */ 207 208 typedef struct NV0000_CTRL_OS_GET_GPU_INFO_PARAMS { 209 NvU32 gpuId; /* IN */ 210 NvU32 minorNum; /* OUT */ 211 } NV0000_CTRL_OS_GET_GPU_INFO_PARAMS; 212 213 /* 214 * NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO 215 * 216 * This command will query the deviceInstance for the specified FD 217 * which is referencing an exported object. 218 * 219 * fd 220 * File descriptor parameter is referencing an exported object on a Unix system. 221 * 222 * deviceInstatnce 223 * This parameter returns a deviceInstance on which the object is located. 224 * 225 * NV_MAX_DEVICES is returned if the object is parented by a client instead 226 * of a device. 227 * 228 * gpuInstanceId 229 * For objects parented by device this parameter returns MIG GPU instance 230 * id the device is subscribed to or NV_U32_MAX if no subscription was made. 231 * 232 * maxObjects 233 * This parameter returns the maximum number of object handles that may be 234 * contained in the file descriptor. 235 * 236 * metadata 237 * This parameter returns the user metadata passed into the 238 * _EXPORT_OBJECTS_TO_FD control call. 239 * 240 * Possible status values returned are: 241 * NV_OK 242 * NV_ERR_INVALID_ARGUMENT 243 * NV_ERR_OBJECT_NOT_FOUND 244 */ 245 246 #define NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO (0x3d08) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_MESSAGE_ID" */ 247 248 #define NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE 64 249 250 #define NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_MESSAGE_ID (0x8U) 251 252 typedef struct NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS { 253 NvS32 fd; /* IN */ 254 NvU32 deviceInstance; /* OUT */ 255 NvU32 gpuInstanceId; /* OUT */ 256 NvU16 maxObjects; /* OUT */ 257 NvU8 metadata[NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE]; /* OUT */ 258 } NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS; 259 260 /* 261 * NV0000_CTRL_CMD_OS_UNIX_REFRESH_RMAPI_DEVICE_LIST 262 * 263 * This command will re-fetch probed GPUs information and update RMAPI library's 264 * internal detected GPU context information accordingly. Without this, GPUs 265 * attached to RM after RMAPI client initialization will not be accessible and 266 * all RMAPI library calls will fail on them. 267 * Currently this is used by NVSwitch Fabric Manager in conjunction with NVSwitch 268 * Shared Virtualization feature where GPUs are hot-plugged to OS/RM (by Hypervisor) 269 * and Fabric Manager is signaled externally by the Hypervisor to initialize those GPUs. 270 * 271 * Possible status values returned are: 272 * NV_OK 273 * NV_ERR_INVALID_STATE 274 * NV_ERR_OPERATING_SYSTEM 275 */ 276 277 #define NV0000_CTRL_CMD_OS_UNIX_REFRESH_RMAPI_DEVICE_LIST (0x3d09) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | 0x9" */ 278 279 /* 280 * This control call has been deprecated. It will be deleted soon. 281 * Use NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD (singular) or 282 * NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD (plural) instead. 283 */ 284 #define NV0000_CTRL_CMD_OS_UNIX_CREATE_EXPORT_OBJECT_FD (0x3d0a) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_PARAMS_MESSAGE_ID" */ 285 286 #define NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_BUFFER_SIZE NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE 287 288 #define NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_PARAMS_MESSAGE_ID (0xAU) 289 290 typedef struct NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_PARAMS { 291 NvHandle hDevice; /* IN */ 292 NvU16 maxObjects; /* IN */ 293 NvU8 metadata[NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_BUFFER_SIZE]; /* IN */ 294 NvS32 fd; /* IN/OUT */ 295 } NV0000_CTRL_OS_UNIX_CREATE_EXPORT_OBJECT_FD_PARAMS; 296 297 /* 298 * NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD 299 * 300 * Exports RM handles to an fd that was provided, also creates an FD if 301 * requested. 302 * 303 * The objects in the 'handles' array are exported into the fd 304 * as the range [index, index + numObjects). 305 * 306 * If index + numObjects is greater than the maxObjects value used 307 * to create the file descriptor, NV_ERR_INVALID_PARAMETER is returned. 308 * 309 * If 'numObjects and 'index' overlap with a prior call, the newer call's RM object 310 * handles will overwrite the previously exported handles from the previous call. 311 * This overlapping behavior can also be used to unexport a handle by setting 312 * the appropriate object in 'objects' to 0. 313 * 314 * fd 315 * A file descriptor. If -1, a new FD will be created. 316 * 317 * hDevice 318 * The owning device of the objects to be exported (must be the same for 319 * all objects). 320 * 321 * maxObjects 322 * The total number of objects that the client wishes to export to the FD. 323 * This parameter will be honored only when the FD is getting created. 324 * 325 * metadata 326 * A buffer for clients to write some metadata to and pass to the importing 327 * client. This parameter will be honored only when the FD is getting 328 * created. 329 * 330 * objects 331 * Array of RM object handles to export to the fd. 332 * 333 * numObjects 334 * The number of handles the user wishes to export in this call. 335 * 336 * index 337 * The index into the export fd at which to start exporting the handles in 338 * 'objects' (for use in iterative calls). 339 * 340 * Possible status values returned are: 341 * NV_OK 342 * NV_ERR_OUT_OF_RANGE 343 * NV_ERR_NOT_SUPPORTED 344 * NV_ERR_OBJECT_NOT_FOUND 345 * NV_ERR_INVALID_OBJECT_HANDLE 346 */ 347 #define NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD (0x3d0b) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS_MESSAGE_ID" */ 348 349 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_MAX_OBJECTS 512 350 351 #define NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS_MESSAGE_ID (0xBU) 352 353 typedef struct NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS { 354 NvS32 fd; /* IN/OUT */ 355 NvHandle hDevice; /* IN */ 356 NvU16 maxObjects; /* IN */ 357 NvU8 metadata[NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE]; /* IN */ 358 NvHandle objects[NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_MAX_OBJECTS]; /* IN */ 359 NvU16 numObjects; /* IN */ 360 NvU16 index; /* IN */ 361 } NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS; 362 363 /* 364 * NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD 365 * 366 * This command can be used to import back RM handles 367 * that were exported to an fd using the 368 * NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD control call. 369 * 370 * If index + numObjects is greater than the maxObjects value used 371 * to create the file descriptor, NV_ERR_INVALID_PARAMETER is returned 372 * and no objects are imported. 373 * 374 * For each valid handle in the 'objects' array parameter at index 'i', 375 * the corresponding object handle at index ('i' + 'index') contained by 376 * the fd will be imported. If the object at index ('i' + 'index') has 377 * not been exported into the fd, no object will be imported. 378 * 379 * If any of handles contained in the 'objects' array parameter are invalid 380 * and the corresponding export object handle is valid, 381 * NV_ERR_INVALID_PARAMETER will be returned and no handles will be imported. 382 * 383 * fd 384 * The export fd on which to import handles out of. 385 * 386 * hParent 387 * The parent RM handle of which all of the exported objects will 388 * be duped under. 389 * 390 * objects 391 * An array of RM handles. The exported objects will be duped under 392 * these handles during the import process. 393 * 394 * objectTypes 395 * An array of RM handle types. The type _NONE will be returned if 396 * the object was not imported. Other possible object types are 397 * mentioned below. 398 * 399 * numObjects 400 * The number of valid object handles in the 'objects' array. This should 401 * be set to the number of objects that the client wishes to import. 402 * 403 * index 404 * The index into the fd in which to start importing from. For 405 * use in iterative calls. 406 * 407 * Possible status values returned are: 408 * NV_OK 409 * NV_ERR_OUT_OF_RANGE 410 * NV_ERR_NOT_SUPPORTED 411 * NV_ERR_OBJECT_NOT_FOUND 412 * NV_ERR_INVALID_OBJECT_HANDLE 413 * NV_ERR_INVALID_PARAMETER 414 */ 415 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD (0x3d0c) /* finn: Evaluated from "(FINN_NV01_ROOT_OS_UNIX_INTERFACE_ID << 8) | NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS_MESSAGE_ID" */ 416 417 // 418 // TODO Bump this back up to 512 after the FLA revamp is complete 419 // 420 #define NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS 128 421 422 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_TYPE_NONE 0 423 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_TYPE_VIDMEM 1 424 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_TYPE_SYSMEM 2 425 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_TYPE_FABRIC 3 426 #define NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_TYPE_FABRIC_MC 4 427 428 #define NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS_MESSAGE_ID (0xCU) 429 430 typedef struct NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS { 431 NvS32 fd; /* IN */ 432 NvHandle hParent; /* IN */ 433 NvHandle objects[NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS]; /* IN */ 434 NvU8 objectTypes[NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS]; /* OUT */ 435 NvU16 numObjects; /* IN */ 436 NvU16 index; /* IN */ 437 } NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS; 438 439 /* _ctrl0000unix_h_ */ 440