4 * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
5 * Author: Alex Williamson <alex.williamson@redhat.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
15 #include <linux/iommu.h>
17 #include <uapi/linux/vfio.h>
20 * struct vfio_device_ops - VFIO bus driver device callbacks
22 * @open: Called when userspace creates new file descriptor for device
23 * @release: Called when userspace releases file descriptor for device
24 * @read: Perform read(2) on device file descriptor
25 * @write: Perform write(2) on device file descriptor
26 * @ioctl: Perform ioctl(2) on device file descriptor, supporting VFIO_DEVICE_*
27 * operations documented below
28 * @mmap: Perform mmap(2) on a region of the device file descriptor
30 struct vfio_device_ops
{
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
,
40 int (*mmap
)(void *device_data
, struct vm_area_struct
*vma
);
43 extern int vfio_add_group_dev(struct device
*dev
,
44 const struct vfio_device_ops
*ops
,
47 extern void *vfio_del_group_dev(struct device
*dev
);
50 * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
52 struct vfio_iommu_driver_ops
{
55 void *(*open
)(unsigned long arg
);
56 void (*release
)(void *iommu_data
);
57 ssize_t (*read
)(void *iommu_data
, char __user
*buf
,
58 size_t count
, loff_t
*ppos
);
59 ssize_t (*write
)(void *iommu_data
, const char __user
*buf
,
60 size_t count
, loff_t
*size
);
61 long (*ioctl
)(void *iommu_data
, unsigned int cmd
,
63 int (*mmap
)(void *iommu_data
, struct vm_area_struct
*vma
);
64 int (*attach_group
)(void *iommu_data
,
65 struct iommu_group
*group
);
66 void (*detach_group
)(void *iommu_data
,
67 struct iommu_group
*group
);
71 extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops
*ops
);
73 extern void vfio_unregister_iommu_driver(
74 const struct vfio_iommu_driver_ops
*ops
);
77 * offsetofend(TYPE, MEMBER)
79 * @TYPE: The type of the structure
80 * @MEMBER: The member within the structure to get the end offset of
82 * Simple helper macro for dealing with variable sized structures passed
83 * from user space. This allows us to easily determine if the provided
84 * structure is sized to include various fields.
86 #define offsetofend(TYPE, MEMBER) ({ \
88 offsetof(TYPE, MEMBER) + sizeof(tmp.MEMBER); }) \
This page took 0.069544 seconds and 6 git commands to generate.