vfio.rst (0bfc6a4ea63c2adac71a824397ef48f28dbc5e47) vfio.rst (6df62c5b05f4ad6876815ea8b8775905a090224a)
1==================================
2VFIO - "Virtual Function I/O" [1]_
3==================================
4
5Many modern system now provide DMA and interrupt remapping facilities
6to help ensure I/O devices behave within the boundaries they've been
7allotted. This includes x86 hardware with AMD-Vi and Intel VT-d,
8POWER systems with Partitionable Endpoints (PEs) and embedded PowerPC

--- 255 unchanged lines hidden (view full) ---

264vfio_register_group_dev() indicates to the core to begin tracking the
265iommu_group of the specified dev and register the dev as owned by a VFIO bus
266driver. Once vfio_register_group_dev() returns it is possible for userspace to
267start accessing the driver, thus the driver should ensure it is completely
268ready before calling it. The driver provides an ops structure for callbacks
269similar to a file operations structure::
270
271 struct vfio_device_ops {
1==================================
2VFIO - "Virtual Function I/O" [1]_
3==================================
4
5Many modern system now provide DMA and interrupt remapping facilities
6to help ensure I/O devices behave within the boundaries they've been
7allotted. This includes x86 hardware with AMD-Vi and Intel VT-d,
8POWER systems with Partitionable Endpoints (PEs) and embedded PowerPC

--- 255 unchanged lines hidden (view full) ---

264vfio_register_group_dev() indicates to the core to begin tracking the
265iommu_group of the specified dev and register the dev as owned by a VFIO bus
266driver. Once vfio_register_group_dev() returns it is possible for userspace to
267start accessing the driver, thus the driver should ensure it is completely
268ready before calling it. The driver provides an ops structure for callbacks
269similar to a file operations structure::
270
271 struct vfio_device_ops {
272 int (*open)(void *device_data);
273 void (*release)(void *device_data);
274 ssize_t (*read)(void *device_data, char __user *buf,
272 int (*open)(struct vfio_device *vdev);
273 void (*release)(struct vfio_device *vdev);
274 ssize_t (*read)(struct vfio_device *vdev, char __user *buf,
275 size_t count, loff_t *ppos);
275 size_t count, loff_t *ppos);
276 ssize_t (*write)(void *device_data, const char __user *buf,
276 ssize_t (*write)(struct vfio_device *vdev,
277 const char __user *buf,
277 size_t size, loff_t *ppos);
278 size_t size, loff_t *ppos);
278 long (*ioctl)(void *device_data, unsigned int cmd,
279 long (*ioctl)(struct vfio_device *vdev, unsigned int cmd,
279 unsigned long arg);
280 unsigned long arg);
280 int (*mmap)(void *device_data, struct vm_area_struct *vma);
281 int (*mmap)(struct vfio_device *vdev,
282 struct vm_area_struct *vma);
281 };
282
283 };
284
283Each function is passed the device_data that was originally registered
285Each function is passed the vdev that was originally registered
284in the vfio_register_group_dev() call above. This allows the bus driver
286in the vfio_register_group_dev() call above. This allows the bus driver
285an easy place to store its opaque, private data. The open/release
287to obtain its private data using container_of(). The open/release
286callbacks are issued when a new file descriptor is created for a
287device (via VFIO_GROUP_GET_DEVICE_FD). The ioctl interface provides
288a direct pass through for VFIO_DEVICE_* ioctls. The read/write/mmap
289interfaces implement the device region access defined by the device's
290own VFIO_DEVICE_GET_REGION_INFO ioctl.
291
292
293PPC64 sPAPR implementation note

--- 232 unchanged lines hidden ---
288callbacks are issued when a new file descriptor is created for a
289device (via VFIO_GROUP_GET_DEVICE_FD). The ioctl interface provides
290a direct pass through for VFIO_DEVICE_* ioctls. The read/write/mmap
291interfaces implement the device region access defined by the device's
292own VFIO_DEVICE_GET_REGION_INFO ioctl.
293
294
295PPC64 sPAPR implementation note

--- 232 unchanged lines hidden ---