~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/iommufd.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Copyright (C) 2021 Intel Corporation
  4  * Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
  5  */
  6 #ifndef __LINUX_IOMMUFD_H
  7 #define __LINUX_IOMMUFD_H
  8 
  9 #include <linux/types.h>
 10 #include <linux/errno.h>
 11 #include <linux/err.h>
 12 
 13 struct device;
 14 struct iommufd_device;
 15 struct page;
 16 struct iommufd_ctx;
 17 struct iommufd_access;
 18 struct file;
 19 struct iommu_group;
 20 
 21 struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
 22                                            struct device *dev, u32 *id);
 23 void iommufd_device_unbind(struct iommufd_device *idev);
 24 
 25 int iommufd_device_attach(struct iommufd_device *idev, u32 *pt_id);
 26 int iommufd_device_replace(struct iommufd_device *idev, u32 *pt_id);
 27 void iommufd_device_detach(struct iommufd_device *idev);
 28 
 29 struct iommufd_ctx *iommufd_device_to_ictx(struct iommufd_device *idev);
 30 u32 iommufd_device_to_id(struct iommufd_device *idev);
 31 
 32 struct iommufd_access_ops {
 33         u8 needs_pin_pages : 1;
 34         void (*unmap)(void *data, unsigned long iova, unsigned long length);
 35 };
 36 
 37 enum {
 38         IOMMUFD_ACCESS_RW_READ = 0,
 39         IOMMUFD_ACCESS_RW_WRITE = 1 << 0,
 40         /* Set if the caller is in a kthread then rw will use kthread_use_mm() */
 41         IOMMUFD_ACCESS_RW_KTHREAD = 1 << 1,
 42 
 43         /* Only for use by selftest */
 44         __IOMMUFD_ACCESS_RW_SLOW_PATH = 1 << 2,
 45 };
 46 
 47 struct iommufd_access *
 48 iommufd_access_create(struct iommufd_ctx *ictx,
 49                       const struct iommufd_access_ops *ops, void *data, u32 *id);
 50 void iommufd_access_destroy(struct iommufd_access *access);
 51 int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id);
 52 int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id);
 53 void iommufd_access_detach(struct iommufd_access *access);
 54 
 55 void iommufd_ctx_get(struct iommufd_ctx *ictx);
 56 
 57 #if IS_ENABLED(CONFIG_IOMMUFD)
 58 struct iommufd_ctx *iommufd_ctx_from_file(struct file *file);
 59 struct iommufd_ctx *iommufd_ctx_from_fd(int fd);
 60 void iommufd_ctx_put(struct iommufd_ctx *ictx);
 61 bool iommufd_ctx_has_group(struct iommufd_ctx *ictx, struct iommu_group *group);
 62 
 63 int iommufd_access_pin_pages(struct iommufd_access *access, unsigned long iova,
 64                              unsigned long length, struct page **out_pages,
 65                              unsigned int flags);
 66 void iommufd_access_unpin_pages(struct iommufd_access *access,
 67                                 unsigned long iova, unsigned long length);
 68 int iommufd_access_rw(struct iommufd_access *access, unsigned long iova,
 69                       void *data, size_t len, unsigned int flags);
 70 int iommufd_vfio_compat_ioas_get_id(struct iommufd_ctx *ictx, u32 *out_ioas_id);
 71 int iommufd_vfio_compat_ioas_create(struct iommufd_ctx *ictx);
 72 int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx);
 73 #else /* !CONFIG_IOMMUFD */
 74 static inline struct iommufd_ctx *iommufd_ctx_from_file(struct file *file)
 75 {
 76         return ERR_PTR(-EOPNOTSUPP);
 77 }
 78 
 79 static inline void iommufd_ctx_put(struct iommufd_ctx *ictx)
 80 {
 81 }
 82 
 83 static inline int iommufd_access_pin_pages(struct iommufd_access *access,
 84                                            unsigned long iova,
 85                                            unsigned long length,
 86                                            struct page **out_pages,
 87                                            unsigned int flags)
 88 {
 89         return -EOPNOTSUPP;
 90 }
 91 
 92 static inline void iommufd_access_unpin_pages(struct iommufd_access *access,
 93                                               unsigned long iova,
 94                                               unsigned long length)
 95 {
 96 }
 97 
 98 static inline int iommufd_access_rw(struct iommufd_access *access, unsigned long iova,
 99                       void *data, size_t len, unsigned int flags)
100 {
101         return -EOPNOTSUPP;
102 }
103 
104 static inline int iommufd_vfio_compat_ioas_create(struct iommufd_ctx *ictx)
105 {
106         return -EOPNOTSUPP;
107 }
108 
109 static inline int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx)
110 {
111         return -EOPNOTSUPP;
112 }
113 #endif /* CONFIG_IOMMUFD */
114 #endif
115 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php