/* * VFIO core * * Copyright (C) 2012 Red Hat, Inc. All rights reserved. * Author: Alex Williamson <alex.williamson@redhat.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Derived from original vfio: * Copyright 2010 Cisco Systems, Inc. All rights reserved. * Author: Tom Lyon, pugs@cisco.com */#include <linux/cdev.h>#include <linux/compat.h>#include <linux/device.h>#include <linux/file.h>#include <linux/anon_inodes.h>#include <linux/fs.h>#include <linux/idr.h>#include <linux/iommu.h>#include <linux/list.h>#include <linux/module.h>#include <linux/mutex.h>#include <linux/rwsem.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/stat.h>#include <linux/string.h>#include <linux/uaccess.h>#include <linux/vfio.h>#include <linux/wait.h>#define DRIVER_VERSION"0.3"#define DRIVER_AUTHOR"Alex Williamson <alex.williamson@redhat.com>"#define DRIVER_DESC"VFIO - User Level meta-driver"static struct vfio {structclass*class;struct list_head iommu_drivers_list;struct mutex iommu_drivers_lock;struct list_head group_list;struct idr group_idr;struct mutex group_lock;struct cdev group_cdev;struct device *dev;
dev_t devt;struct cdev cdev;
wait_queue_head_t release_q;} vfio;struct vfio_iommu_driver {const struct vfio_iommu_driver_ops *ops;struct list_head vfio_next;};struct vfio_container {struct kref kref;struct list_head group_list;struct rw_semaphore group_lock;struct vfio_iommu_driver *iommu_driver;void*iommu_data;};struct vfio_group {struct kref kref;int minor;
atomic_t container_users;struct iommu_group *iommu_group;struct vfio_container *container;struct list_head device_list;struct mutex device_lock;struct d