4 * Copyright(c) 2017 6WIND S.A. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of 6WIND nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <linux/vfio.h>
39 #define VFIO_DIR "/dev/vfio"
40 #define VFIO_CONTAINER_PATH "/dev/vfio/vfio"
41 #define VFIO_GROUP_FMT "/dev/vfio/%u"
42 #define VFIO_NOIOMMU_GROUP_FMT "/dev/vfio/noiommu-%u"
43 #define VFIO_GET_REGION_ADDR(x) ((uint64_t) x << 40ULL)
44 #define VFIO_GET_REGION_IDX(x) (x >> 40)
45 #define VFIO_NOIOMMU_MODE \
46 "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
49 * Setup vfio_cfg for the device identified by its address.
50 * It discovers the configured I/O MMU groups or sets a new one for the device.
51 * If a new groups is assigned, the DMA mapping is performed.
53 * This function is only relevant to linux and will return
71 * >1 if the device cannot be managed this way.
73 int vfio_setup_device(const char *sysfs_base, const char *dev_addr,
74 int *vfio_dev_fd, struct vfio_device_info *device_info);
77 * Release a device mapped to a VFIO-managed I/O MMU group.
79 * This function is only relevant to linux and will return
95 int vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd);
98 * Enable a VFIO-related kmod.
100 * This function is only relevant to linux and will return
104 * kernel module name.
110 int vfio_enable(const char *modname);
113 * Check whether a VFIO-related kmod is enabled.
115 * This function is only relevant to linux and will return
119 * kernel module name.
125 int vfio_is_enabled(const char *modname);
128 * Whether VFIO NOIOMMU mode is enabled.
130 * This function is only relevant to linux and will return
137 int vfio_noiommu_is_enabled(void);
139 #endif /* _RTE_VFIO_H_ */