include/linux/vfio_pci_core.h

Source file repositories/reference/linux-study-clean/include/linux/vfio_pci_core.h

File Facts

System
Linux kernel
Corpus path
include/linux/vfio_pci_core.h
Extension
.h
Size
8665 bytes
Lines
260
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct vfio_pci_eventfd {
	struct eventfd_ctx	*ctx;
	struct rcu_head		rcu;
};

struct vfio_pci_regops {
	ssize_t (*rw)(struct vfio_pci_core_device *vdev, char __user *buf,
		      size_t count, loff_t *ppos, bool iswrite);
	void	(*release)(struct vfio_pci_core_device *vdev,
			   struct vfio_pci_region *region);
	int	(*mmap)(struct vfio_pci_core_device *vdev,
			struct vfio_pci_region *region,
			struct vm_area_struct *vma);
	int	(*add_capability)(struct vfio_pci_core_device *vdev,
				  struct vfio_pci_region *region,
				  struct vfio_info_cap *caps);
};

struct vfio_pci_region {
	u32				type;
	u32				subtype;
	const struct vfio_pci_regops	*ops;
	void				*data;
	size_t				size;
	u32				flags;
};

struct vfio_pci_device_ops {
	int (*get_dmabuf_phys)(struct vfio_pci_core_device *vdev,
			       struct p2pdma_provider **provider,
			       unsigned int region_index,
			       struct phys_vec *phys_vec,
			       struct vfio_region_dma_range *dma_ranges,
			       size_t nr_ranges);
};

#if IS_ENABLED(CONFIG_VFIO_PCI_DMABUF)
int vfio_pci_core_fill_phys_vec(struct phys_vec *phys_vec,
				struct vfio_region_dma_range *dma_ranges,
				size_t nr_ranges, phys_addr_t start,
				phys_addr_t len);
int vfio_pci_core_get_dmabuf_phys(struct vfio_pci_core_device *vdev,
				  struct p2pdma_provider **provider,
				  unsigned int region_index,
				  struct phys_vec *phys_vec,
				  struct vfio_region_dma_range *dma_ranges,
				  size_t nr_ranges);
#else
static inline int
vfio_pci_core_fill_phys_vec(struct phys_vec *phys_vec,
			    struct vfio_region_dma_range *dma_ranges,
			    size_t nr_ranges, phys_addr_t start,
			    phys_addr_t len)
{
	return -EINVAL;
}
static inline int vfio_pci_core_get_dmabuf_phys(
	struct vfio_pci_core_device *vdev, struct p2pdma_provider **provider,
	unsigned int region_index, struct phys_vec *phys_vec,
	struct vfio_region_dma_range *dma_ranges, size_t nr_ranges)
{
	return -EOPNOTSUPP;
}
#endif

struct vfio_pci_core_device {
	struct vfio_device	vdev;
	struct pci_dev		*pdev;
	const struct vfio_pci_device_ops *pci_ops;
	void __iomem		*barmap[PCI_STD_NUM_BARS];
	bool			bar_mmap_supported[PCI_STD_NUM_BARS];
	u8			*pci_config_map;
	u8			*vconfig;
	struct perm_bits	*msi_perm;
	spinlock_t		irqlock;
	struct mutex		igate;
	struct xarray		ctx;
	int			irq_type;
	int			num_regions;
	struct vfio_pci_region	*region;
	u8			msi_qmax;
	u8			msix_bar;
	u16			msix_size;
	u32			msix_offset;
	u32			rbar[7];
	bool			has_dyn_msix:1;
	bool			pci_2_3:1;
	bool			virq_disabled:1;
	bool			reset_works:1;
	bool			extended_caps:1;

Annotation

Implementation Notes