1
2
3
4
5
6
7
8
9
10
11#ifndef VFIO_H
12#define VFIO_H
13
14
15#include <linux/iommu.h>
16#include <linux/mm.h>
17#include <uapi/linux/vfio.h>
18
19
20
21
22
23
24
25
26
27
28
29
30struct vfio_device_ops {
31 char *name;
32 int (*open)(void *device_data);
33 void (*release)(void *device_data);
34 ssize_t (*read)(void *device_data, char __user *buf,
35 size_t count, loff_t *ppos);
36 ssize_t (*write)(void *device_data, const char __user *buf,
37 size_t count, loff_t *size);
38 long (*ioctl)(void *device_data, unsigned int cmd,
39 unsigned long arg);
40 int (*mmap)(void *device_data, struct vm_area_struct *vma);
41};
42
43extern int vfio_add_group_dev(struct device *dev,
44 const struct vfio_device_ops *ops,
45 void *device_data);
46
47extern void *vfio_del_group_dev(struct device *dev);
48extern struct vfio_device *vfio_device_get_from_dev(struct device *dev);
49extern void vfio_device_put(struct vfio_device *device);
50extern void *vfio_device_data(struct vfio_device *device);
51
52
53
54
55struct vfio_iommu_driver_ops {
56 char *name;
57 struct module *owner;
58 void *(*open)(unsigned long arg);
59 void (*release)(void *iommu_data);
60 ssize_t (*read)(void *iommu_data, char __user *buf,
61 size_t count, loff_t *ppos);
62 ssize_t (*write)(void *iommu_data, const char __user *buf,
63 size_t count, loff_t *size);
64 long (*ioctl)(void *iommu_data, unsigned int cmd,
65 unsigned long arg);
66 int (*mmap)(void *iommu_data, struct vm_area_struct *vma);
67 int (*attach_group)(void *iommu_data,
68 struct iommu_group *group);
69 void (*detach_group)(void *iommu_data,
70 struct iommu_group *group);
71
72};
73
74extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
75
76extern void vfio_unregister_iommu_driver(
77 const struct vfio_iommu_driver_ops *ops);
78
79
80
81
82
83
84
85
86
87
88
89#define offsetofend(TYPE, MEMBER) ({ \
90 TYPE tmp; \
91 offsetof(TYPE, MEMBER) + sizeof(tmp.MEMBER); }) \
92
93#endif
94