File Index
Files and directories
Sign in
FILE

vfio_pci_priv.h

File preview with syntax highlighting.

linux-6.19.14/drivers/vfio/pci/vfio_pci_priv.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2#ifndef VFIO_PCI_PRIV_H
  3#define VFIO_PCI_PRIV_H
  4
  5#include <linux/vfio_pci_core.h>
  6
  7/* Special capability IDs predefined access */
  8#define PCI_CAP_ID_INVALID		0xFF	/* default raw access */
  9#define PCI_CAP_ID_INVALID_VIRT		0xFE	/* default virt access */
 10
 11/* Cap maximum number of ioeventfds per device (arbitrary) */
 12#define VFIO_PCI_IOEVENTFD_MAX		1000
 13
 14struct vfio_pci_ioeventfd {
 15	struct list_head	next;
 16	struct vfio_pci_core_device	*vdev;
 17	struct virqfd		*virqfd;
 18	void __iomem		*addr;
 19	uint64_t		data;
 20	loff_t			pos;
 21	int			bar;
 22	int			count;
 23	bool			test_mem;
 24};
 25
 26bool vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
 27void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
 28
 29int vfio_pci_eventfd_replace_locked(struct vfio_pci_core_device *vdev,
 30				    struct vfio_pci_eventfd __rcu **peventfd,
 31				    struct eventfd_ctx *ctx);
 32
 33int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags,
 34			    unsigned index, unsigned start, unsigned count,
 35			    void *data);
 36
 37ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev, char __user *buf,
 38			   size_t count, loff_t *ppos, bool iswrite);
 39
 40ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
 41			size_t count, loff_t *ppos, bool iswrite);
 42
 43#ifdef CONFIG_VFIO_PCI_VGA
 44ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf,
 45			size_t count, loff_t *ppos, bool iswrite);
 46#else
 47static inline ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev,
 48				      char __user *buf, size_t count,
 49				      loff_t *ppos, bool iswrite)
 50{
 51	return -EINVAL;
 52}
 53#endif
 54
 55int vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
 56		       uint64_t data, int count, int fd);
 57
 58int vfio_pci_init_perm_bits(void);
 59void vfio_pci_uninit_perm_bits(void);
 60
 61int vfio_config_init(struct vfio_pci_core_device *vdev);
 62void vfio_config_free(struct vfio_pci_core_device *vdev);
 63
 64int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev,
 65			     pci_power_t state);
 66
 67void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev);
 68u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev);
 69void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
 70					u16 cmd);
 71
 72#ifdef CONFIG_VFIO_PCI_IGD
 73bool vfio_pci_is_intel_display(struct pci_dev *pdev);
 74int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
 75#else
 76static inline bool vfio_pci_is_intel_display(struct pci_dev *pdev)
 77{
 78	return false;
 79}
 80
 81static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
 82{
 83	return -ENODEV;
 84}
 85#endif
 86
 87#ifdef CONFIG_VFIO_PCI_ZDEV_KVM
 88int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
 89				struct vfio_info_cap *caps);
 90int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
 91void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
 92#else
 93static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
 94					      struct vfio_info_cap *caps)
 95{
 96	return -ENODEV;
 97}
 98
 99static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
100{
101	return 0;
102}
103
104static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
105{}
106#endif
107
108static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
109{
110	return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
111}
112
113#ifdef CONFIG_VFIO_PCI_DMABUF
114int vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,
115				  struct vfio_device_feature_dma_buf __user *arg,
116				  size_t argsz);
117void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_device *vdev);
118void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev, bool revoked);
119#else
120static inline int
121vfio_pci_core_feature_dma_buf(struct vfio_pci_core_device *vdev, u32 flags,
122			      struct vfio_device_feature_dma_buf __user *arg,
123			      size_t argsz)
124{
125	return -ENOTTY;
126}
127static inline void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_device *vdev)
128{
129}
130static inline void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev,
131					 bool revoked)
132{
133}
134#endif
135
136#endif
~/ Read-only file preview.