/* SPDX-FileCopyrightText: Copyright (c) 2016-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: MIT */ #ifndef _NV_VGPU_VFIO_INTERFACE_H_ #define _NV_VGPU_VFIO_INTERFACE_H_ #include #include #include #include /* Use standard kernel types */ typedef int NV_STATUS; typedef unsigned char NvU8; typedef unsigned int NvU32; typedef unsigned short NvU16; typedef unsigned long long NvU64; typedef int NvS32; typedef unsigned char NvBool; #define NV_OK 0 #define NV_ERR_NOT_SUPPORTED -1 #define NV_ERR_GENERIC -2 #define NV_ERR_INVALID_ARGUMENT -3 #define NV_ERR_NO_MEMORY -4 typedef enum { VGPU_DEVICE_STATE_UNINITIALIZED = 0, VGPU_DEVICE_STATE_INITIALIZING, VGPU_DEVICE_STATE_READY, VGPU_DEVICE_STATE_RUNNING, VGPU_DEVICE_STATE_SUSPENDED, VGPU_DEVICE_STATE_ERROR, VGPU_DEVICE_STATE_MIGRATING, } VGPU_DEVICE_STATE; typedef NV_STATUS (*vgpu_vfio_probe_t)(struct pci_dev *, NvU32, NvU32 *); typedef void (*vgpu_vfio_remove_t)(struct pci_dev *); typedef NV_STATUS (*vgpu_vfio_inject_interrupt_t)(void *); typedef struct { vgpu_vfio_probe_t probe; vgpu_vfio_remove_t remove; vgpu_vfio_inject_interrupt_t inject_interrupt; } vgpu_vfio_ops_t; typedef NV_STATUS (*vgpu_vfio_vgpu_create_t) (struct pci_dev *dev, const NvU8 *uuid, NvU32 vgpu_type_id, NvU16 *vgpu_id, NvU32 *gpu_pci_id, NvU32 gpu_pci_bdf); typedef NV_STATUS (*vgpu_vfio_vgpu_destroy_t) (const NvU8 *uuid, NvU16 vgpu_id); typedef NV_STATUS (*vgpu_vfio_start_t) (const NvU8 *uuid, void *wait_queue, NvS32 *return_status, NvU8 *vm_name, NvU32 qemu_pid); typedef NV_STATUS (*vgpu_vfio_bar_info_t) (struct pci_dev *dev, const NvU8 *, NvU64 *, NvU32 bar_index, void *); typedef NV_STATUS (*vgpu_vfio_get_description) (struct pci_dev *, NvU32, char *); typedef NV_STATUS (*vgpu_vfio_get_name) (struct pci_dev *, NvU32, char *); typedef NV_STATUS (*vgpu_vfio_get_instance) (struct pci_dev *, NvU32, char *); typedef NV_STATUS (*vgpu_vfio_sparse_mmap_t) (struct pci_dev *, const NvU8 *, NvU64 **, NvU64 **, NvU32 *); typedef void (*vgpu_vfio_update_request_t) (const NvU8 *, NvU64 *, NvU64 *, VGPU_DEVICE_STATE, const char *); typedef struct { const char *version_string; vgpu_vfio_vgpu_create_t vgpu_create; vgpu_vfio_vgpu_destroy_t vgpu_delete; vgpu_vfio_bar_info_t vgpu_bar_info; vgpu_vfio_start_t vgpu_start; vgpu_vfio_get_description get_description; vgpu_vfio_get_instance get_instances; vgpu_vfio_get_name get_name; vgpu_vfio_sparse_mmap_t get_sparse_mmap; vgpu_vfio_update_request_t update_request; } rm_vgpu_vfio_ops_t; extern NV_STATUS nvidia_vgpu_vfio_set_ops(vgpu_vfio_ops_t *vgpu_vfio_ops); extern NV_STATUS nvidia_vgpu_vfio_get_ops(rm_vgpu_vfio_ops_t *ops); extern NV_STATUS nvidia_vgpu_vfio_probe(struct pci_dev *); extern void nvidia_vgpu_vfio_remove(struct pci_dev *, NvBool); #endif /* _NV_VGPU_VFIO_INTERFACE_H_ */