Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/linux
File: vfio.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
/*
[1] Fix | Delete
* VFIO API definition
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright (C) 2012 Red Hat, Inc. All rights reserved.
[4] Fix | Delete
* Author: Alex Williamson <alex.williamson@redhat.com>
[5] Fix | Delete
*
[6] Fix | Delete
* This program is free software; you can redistribute it and/or modify
[7] Fix | Delete
* it under the terms of the GNU General Public License version 2 as
[8] Fix | Delete
* published by the Free Software Foundation.
[9] Fix | Delete
*/
[10] Fix | Delete
#ifndef VFIO_H
[11] Fix | Delete
#define VFIO_H
[12] Fix | Delete
[13] Fix | Delete
#include <linux/types.h>
[14] Fix | Delete
#include <linux/ioctl.h>
[15] Fix | Delete
[16] Fix | Delete
#define VFIO_API_VERSION 0
[17] Fix | Delete
[18] Fix | Delete
[19] Fix | Delete
/* Kernel & User level defines for VFIO IOCTLs. */
[20] Fix | Delete
[21] Fix | Delete
/* Extensions */
[22] Fix | Delete
[23] Fix | Delete
#define VFIO_TYPE1_IOMMU 1
[24] Fix | Delete
#define VFIO_SPAPR_TCE_IOMMU 2
[25] Fix | Delete
#define VFIO_TYPE1v2_IOMMU 3
[26] Fix | Delete
/*
[27] Fix | Delete
* IOMMU enforces DMA cache coherence (ex. PCIe NoSnoop stripping). This
[28] Fix | Delete
* capability is subject to change as groups are added or removed.
[29] Fix | Delete
*/
[30] Fix | Delete
#define VFIO_DMA_CC_IOMMU 4
[31] Fix | Delete
[32] Fix | Delete
/* Check if EEH is supported */
[33] Fix | Delete
#define VFIO_EEH 5
[34] Fix | Delete
[35] Fix | Delete
/* Two-stage IOMMU */
[36] Fix | Delete
#define VFIO_TYPE1_NESTING_IOMMU 6 /* Implies v2 */
[37] Fix | Delete
[38] Fix | Delete
#define VFIO_SPAPR_TCE_v2_IOMMU 7
[39] Fix | Delete
[40] Fix | Delete
/*
[41] Fix | Delete
* The No-IOMMU IOMMU offers no translation or isolation for devices and
[42] Fix | Delete
* supports no ioctls outside of VFIO_CHECK_EXTENSION. Use of VFIO's No-IOMMU
[43] Fix | Delete
* code will taint the host kernel and should be used with extreme caution.
[44] Fix | Delete
*/
[45] Fix | Delete
#define VFIO_NOIOMMU_IOMMU 8
[46] Fix | Delete
[47] Fix | Delete
/*
[48] Fix | Delete
* The IOCTL interface is designed for extensibility by embedding the
[49] Fix | Delete
* structure length (argsz) and flags into structures passed between
[50] Fix | Delete
* kernel and userspace. We therefore use the _IO() macro for these
[51] Fix | Delete
* defines to avoid implicitly embedding a size into the ioctl request.
[52] Fix | Delete
* As structure fields are added, argsz will increase to match and flag
[53] Fix | Delete
* bits will be defined to indicate additional fields with valid data.
[54] Fix | Delete
* It's *always* the caller's responsibility to indicate the size of
[55] Fix | Delete
* the structure passed by setting argsz appropriately.
[56] Fix | Delete
*/
[57] Fix | Delete
[58] Fix | Delete
#define VFIO_TYPE (';')
[59] Fix | Delete
#define VFIO_BASE 100
[60] Fix | Delete
[61] Fix | Delete
/*
[62] Fix | Delete
* For extension of INFO ioctls, VFIO makes use of a capability chain
[63] Fix | Delete
* designed after PCI/e capabilities. A flag bit indicates whether
[64] Fix | Delete
* this capability chain is supported and a field defined in the fixed
[65] Fix | Delete
* structure defines the offset of the first capability in the chain.
[66] Fix | Delete
* This field is only valid when the corresponding bit in the flags
[67] Fix | Delete
* bitmap is set. This offset field is relative to the start of the
[68] Fix | Delete
* INFO buffer, as is the next field within each capability header.
[69] Fix | Delete
* The id within the header is a shared address space per INFO ioctl,
[70] Fix | Delete
* while the version field is specific to the capability id. The
[71] Fix | Delete
* contents following the header are specific to the capability id.
[72] Fix | Delete
*/
[73] Fix | Delete
struct vfio_info_cap_header {
[74] Fix | Delete
__u16 id; /* Identifies capability */
[75] Fix | Delete
__u16 version; /* Version specific to the capability ID */
[76] Fix | Delete
__u32 next; /* Offset of next capability */
[77] Fix | Delete
};
[78] Fix | Delete
[79] Fix | Delete
/*
[80] Fix | Delete
* Callers of INFO ioctls passing insufficiently sized buffers will see
[81] Fix | Delete
* the capability chain flag bit set, a zero value for the first capability
[82] Fix | Delete
* offset (if available within the provided argsz), and argsz will be
[83] Fix | Delete
* updated to report the necessary buffer size. For compatibility, the
[84] Fix | Delete
* INFO ioctl will not report error in this case, but the capability chain
[85] Fix | Delete
* will not be available.
[86] Fix | Delete
*/
[87] Fix | Delete
[88] Fix | Delete
/* -------- IOCTLs for VFIO file descriptor (/dev/vfio/vfio) -------- */
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* VFIO_GET_API_VERSION - _IO(VFIO_TYPE, VFIO_BASE + 0)
[92] Fix | Delete
*
[93] Fix | Delete
* Report the version of the VFIO API. This allows us to bump the entire
[94] Fix | Delete
* API version should we later need to add or change features in incompatible
[95] Fix | Delete
* ways.
[96] Fix | Delete
* Return: VFIO_API_VERSION
[97] Fix | Delete
* Availability: Always
[98] Fix | Delete
*/
[99] Fix | Delete
#define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0)
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* VFIO_CHECK_EXTENSION - _IOW(VFIO_TYPE, VFIO_BASE + 1, __u32)
[103] Fix | Delete
*
[104] Fix | Delete
* Check whether an extension is supported.
[105] Fix | Delete
* Return: 0 if not supported, 1 (or some other positive integer) if supported.
[106] Fix | Delete
* Availability: Always
[107] Fix | Delete
*/
[108] Fix | Delete
#define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1)
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* VFIO_SET_IOMMU - _IOW(VFIO_TYPE, VFIO_BASE + 2, __s32)
[112] Fix | Delete
*
[113] Fix | Delete
* Set the iommu to the given type. The type must be supported by an
[114] Fix | Delete
* iommu driver as verified by calling CHECK_EXTENSION using the same
[115] Fix | Delete
* type. A group must be set to this file descriptor before this
[116] Fix | Delete
* ioctl is available. The IOMMU interfaces enabled by this call are
[117] Fix | Delete
* specific to the value set.
[118] Fix | Delete
* Return: 0 on success, -errno on failure
[119] Fix | Delete
* Availability: When VFIO group attached
[120] Fix | Delete
*/
[121] Fix | Delete
#define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2)
[122] Fix | Delete
[123] Fix | Delete
/* -------- IOCTLs for GROUP file descriptors (/dev/vfio/$GROUP) -------- */
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* VFIO_GROUP_GET_STATUS - _IOR(VFIO_TYPE, VFIO_BASE + 3,
[127] Fix | Delete
* struct vfio_group_status)
[128] Fix | Delete
*
[129] Fix | Delete
* Retrieve information about the group. Fills in provided
[130] Fix | Delete
* struct vfio_group_info. Caller sets argsz.
[131] Fix | Delete
* Return: 0 on succes, -errno on failure.
[132] Fix | Delete
* Availability: Always
[133] Fix | Delete
*/
[134] Fix | Delete
struct vfio_group_status {
[135] Fix | Delete
__u32 argsz;
[136] Fix | Delete
__u32 flags;
[137] Fix | Delete
#define VFIO_GROUP_FLAGS_VIABLE (1 << 0)
[138] Fix | Delete
#define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1)
[139] Fix | Delete
};
[140] Fix | Delete
#define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3)
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* VFIO_GROUP_SET_CONTAINER - _IOW(VFIO_TYPE, VFIO_BASE + 4, __s32)
[144] Fix | Delete
*
[145] Fix | Delete
* Set the container for the VFIO group to the open VFIO file
[146] Fix | Delete
* descriptor provided. Groups may only belong to a single
[147] Fix | Delete
* container. Containers may, at their discretion, support multiple
[148] Fix | Delete
* groups. Only when a container is set are all of the interfaces
[149] Fix | Delete
* of the VFIO file descriptor and the VFIO group file descriptor
[150] Fix | Delete
* available to the user.
[151] Fix | Delete
* Return: 0 on success, -errno on failure.
[152] Fix | Delete
* Availability: Always
[153] Fix | Delete
*/
[154] Fix | Delete
#define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4)
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* VFIO_GROUP_UNSET_CONTAINER - _IO(VFIO_TYPE, VFIO_BASE + 5)
[158] Fix | Delete
*
[159] Fix | Delete
* Remove the group from the attached container. This is the
[160] Fix | Delete
* opposite of the SET_CONTAINER call and returns the group to
[161] Fix | Delete
* an initial state. All device file descriptors must be released
[162] Fix | Delete
* prior to calling this interface. When removing the last group
[163] Fix | Delete
* from a container, the IOMMU will be disabled and all state lost,
[164] Fix | Delete
* effectively also returning the VFIO file descriptor to an initial
[165] Fix | Delete
* state.
[166] Fix | Delete
* Return: 0 on success, -errno on failure.
[167] Fix | Delete
* Availability: When attached to container
[168] Fix | Delete
*/
[169] Fix | Delete
#define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5)
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* VFIO_GROUP_GET_DEVICE_FD - _IOW(VFIO_TYPE, VFIO_BASE + 6, char)
[173] Fix | Delete
*
[174] Fix | Delete
* Return a new file descriptor for the device object described by
[175] Fix | Delete
* the provided string. The string should match a device listed in
[176] Fix | Delete
* the devices subdirectory of the IOMMU group sysfs entry. The
[177] Fix | Delete
* group containing the device must already be added to this context.
[178] Fix | Delete
* Return: new file descriptor on success, -errno on failure.
[179] Fix | Delete
* Availability: When attached to container
[180] Fix | Delete
*/
[181] Fix | Delete
#define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6)
[182] Fix | Delete
[183] Fix | Delete
/* --------------- IOCTLs for DEVICE file descriptors --------------- */
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* VFIO_DEVICE_GET_INFO - _IOR(VFIO_TYPE, VFIO_BASE + 7,
[187] Fix | Delete
* struct vfio_device_info)
[188] Fix | Delete
*
[189] Fix | Delete
* Retrieve information about the device. Fills in provided
[190] Fix | Delete
* struct vfio_device_info. Caller sets argsz.
[191] Fix | Delete
* Return: 0 on success, -errno on failure.
[192] Fix | Delete
*/
[193] Fix | Delete
struct vfio_device_info {
[194] Fix | Delete
__u32 argsz;
[195] Fix | Delete
__u32 flags;
[196] Fix | Delete
#define VFIO_DEVICE_FLAGS_RESET (1 << 0) /* Device supports reset */
[197] Fix | Delete
#define VFIO_DEVICE_FLAGS_PCI (1 << 1) /* vfio-pci device */
[198] Fix | Delete
#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) /* vfio-platform device */
[199] Fix | Delete
#define VFIO_DEVICE_FLAGS_AMBA (1 << 3) /* vfio-amba device */
[200] Fix | Delete
#define VFIO_DEVICE_FLAGS_CCW (1 << 4) /* vfio-ccw device */
[201] Fix | Delete
#define VFIO_DEVICE_FLAGS_AP (1 << 5) /* vfio-ap device */
[202] Fix | Delete
#define VFIO_DEVICE_FLAGS_CAPS (1 << 7) /* Info supports caps */
[203] Fix | Delete
__u32 num_regions; /* Max region index + 1 */
[204] Fix | Delete
__u32 num_irqs; /* Max IRQ index + 1 */
[205] Fix | Delete
__u32 cap_offset; /* Offset within info struct of first cap */
[206] Fix | Delete
};
[207] Fix | Delete
#define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
[208] Fix | Delete
[209] Fix | Delete
/*
[210] Fix | Delete
* Vendor driver using Mediated device framework should provide device_api
[211] Fix | Delete
* attribute in supported type attribute groups. Device API string should be one
[212] Fix | Delete
* of the following corresponding to device flags in vfio_device_info structure.
[213] Fix | Delete
*/
[214] Fix | Delete
[215] Fix | Delete
#define VFIO_DEVICE_API_PCI_STRING "vfio-pci"
[216] Fix | Delete
#define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform"
[217] Fix | Delete
#define VFIO_DEVICE_API_AMBA_STRING "vfio-amba"
[218] Fix | Delete
#define VFIO_DEVICE_API_CCW_STRING "vfio-ccw"
[219] Fix | Delete
#define VFIO_DEVICE_API_AP_STRING "vfio-ap"
[220] Fix | Delete
[221] Fix | Delete
/*
[222] Fix | Delete
* The following capabilities are unique to s390 zPCI devices. Their contents
[223] Fix | Delete
* are further-defined in vfio_zdev.h
[224] Fix | Delete
*/
[225] Fix | Delete
#define VFIO_DEVICE_INFO_CAP_ZPCI_BASE 1
[226] Fix | Delete
#define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP 2
[227] Fix | Delete
#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL 3
[228] Fix | Delete
#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP 4
[229] Fix | Delete
[230] Fix | Delete
/**
[231] Fix | Delete
* VFIO_DEVICE_GET_REGION_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 8,
[232] Fix | Delete
* struct vfio_region_info)
[233] Fix | Delete
*
[234] Fix | Delete
* Retrieve information about a device region. Caller provides
[235] Fix | Delete
* struct vfio_region_info with index value set. Caller sets argsz.
[236] Fix | Delete
* Implementation of region mapping is bus driver specific. This is
[237] Fix | Delete
* intended to describe MMIO, I/O port, as well as bus specific
[238] Fix | Delete
* regions (ex. PCI config space). Zero sized regions may be used
[239] Fix | Delete
* to describe unimplemented regions (ex. unimplemented PCI BARs).
[240] Fix | Delete
* Return: 0 on success, -errno on failure.
[241] Fix | Delete
*/
[242] Fix | Delete
struct vfio_region_info {
[243] Fix | Delete
__u32 argsz;
[244] Fix | Delete
__u32 flags;
[245] Fix | Delete
#define VFIO_REGION_INFO_FLAG_READ (1 << 0) /* Region supports read */
[246] Fix | Delete
#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1) /* Region supports write */
[247] Fix | Delete
#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2) /* Region supports mmap */
[248] Fix | Delete
#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3) /* Info supports caps */
[249] Fix | Delete
__u32 index; /* Region index */
[250] Fix | Delete
__u32 cap_offset; /* Offset within info struct of first cap */
[251] Fix | Delete
__u64 size; /* Region size (bytes) */
[252] Fix | Delete
__u64 offset; /* Region offset from start of device fd */
[253] Fix | Delete
};
[254] Fix | Delete
#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
[255] Fix | Delete
[256] Fix | Delete
/*
[257] Fix | Delete
* The sparse mmap capability allows finer granularity of specifying areas
[258] Fix | Delete
* within a region with mmap support. When specified, the user should only
[259] Fix | Delete
* mmap the offset ranges specified by the areas array. mmaps outside of the
[260] Fix | Delete
* areas specified may fail (such as the range covering a PCI MSI-X table) or
[261] Fix | Delete
* may result in improper device behavior.
[262] Fix | Delete
*
[263] Fix | Delete
* The structures below define version 1 of this capability.
[264] Fix | Delete
*/
[265] Fix | Delete
#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
[266] Fix | Delete
[267] Fix | Delete
struct vfio_region_sparse_mmap_area {
[268] Fix | Delete
__u64 offset; /* Offset of mmap'able area within region */
[269] Fix | Delete
__u64 size; /* Size of mmap'able area */
[270] Fix | Delete
};
[271] Fix | Delete
[272] Fix | Delete
struct vfio_region_info_cap_sparse_mmap {
[273] Fix | Delete
struct vfio_info_cap_header header;
[274] Fix | Delete
__u32 nr_areas;
[275] Fix | Delete
__u32 reserved;
[276] Fix | Delete
struct vfio_region_sparse_mmap_area areas[];
[277] Fix | Delete
};
[278] Fix | Delete
[279] Fix | Delete
/*
[280] Fix | Delete
* The device specific type capability allows regions unique to a specific
[281] Fix | Delete
* device or class of devices to be exposed. This helps solve the problem for
[282] Fix | Delete
* vfio bus drivers of defining which region indexes correspond to which region
[283] Fix | Delete
* on the device, without needing to resort to static indexes, as done by
[284] Fix | Delete
* vfio-pci. For instance, if we were to go back in time, we might remove
[285] Fix | Delete
* VFIO_PCI_VGA_REGION_INDEX and let vfio-pci simply define that all indexes
[286] Fix | Delete
* greater than or equal to VFIO_PCI_NUM_REGIONS are device specific and we'd
[287] Fix | Delete
* make a "VGA" device specific type to describe the VGA access space. This
[288] Fix | Delete
* means that non-VGA devices wouldn't need to waste this index, and thus the
[289] Fix | Delete
* address space associated with it due to implementation of device file
[290] Fix | Delete
* descriptor offsets in vfio-pci.
[291] Fix | Delete
*
[292] Fix | Delete
* The current implementation is now part of the user ABI, so we can't use this
[293] Fix | Delete
* for VGA, but there are other upcoming use cases, such as opregions for Intel
[294] Fix | Delete
* IGD devices and framebuffers for vGPU devices. We missed VGA, but we'll
[295] Fix | Delete
* use this for future additions.
[296] Fix | Delete
*
[297] Fix | Delete
* The structure below defines version 1 of this capability.
[298] Fix | Delete
*/
[299] Fix | Delete
#define VFIO_REGION_INFO_CAP_TYPE 2
[300] Fix | Delete
[301] Fix | Delete
struct vfio_region_info_cap_type {
[302] Fix | Delete
struct vfio_info_cap_header header;
[303] Fix | Delete
__u32 type; /* global per bus driver */
[304] Fix | Delete
__u32 subtype; /* type specific */
[305] Fix | Delete
};
[306] Fix | Delete
[307] Fix | Delete
/*
[308] Fix | Delete
* List of region types, global per bus driver.
[309] Fix | Delete
* If you introduce a new type, please add it here.
[310] Fix | Delete
*/
[311] Fix | Delete
[312] Fix | Delete
/* PCI region type containing a PCI vendor part */
[313] Fix | Delete
#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
[314] Fix | Delete
#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
[315] Fix | Delete
#define VFIO_REGION_TYPE_GFX (1)
[316] Fix | Delete
#define VFIO_REGION_TYPE_CCW (2)
[317] Fix | Delete
#define VFIO_REGION_TYPE_MIGRATION (3)
[318] Fix | Delete
[319] Fix | Delete
/* sub-types for VFIO_REGION_TYPE_PCI_* */
[320] Fix | Delete
[321] Fix | Delete
/* 8086 vendor PCI sub-types */
[322] Fix | Delete
#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
[323] Fix | Delete
#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
[324] Fix | Delete
#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
[325] Fix | Delete
[326] Fix | Delete
/* 10de vendor PCI sub-types */
[327] Fix | Delete
/*
[328] Fix | Delete
* NVIDIA GPU NVlink2 RAM is coherent RAM mapped onto the host address space.
[329] Fix | Delete
*/
[330] Fix | Delete
#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
[331] Fix | Delete
[332] Fix | Delete
/* 1014 vendor PCI sub-types */
[333] Fix | Delete
/*
[334] Fix | Delete
* IBM NPU NVlink2 ATSD (Address Translation Shootdown) register of NPU
[335] Fix | Delete
* to do TLB invalidation on a GPU.
[336] Fix | Delete
*/
[337] Fix | Delete
#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
[338] Fix | Delete
[339] Fix | Delete
/* sub-types for VFIO_REGION_TYPE_GFX */
[340] Fix | Delete
#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
[341] Fix | Delete
[342] Fix | Delete
/**
[343] Fix | Delete
* struct vfio_region_gfx_edid - EDID region layout.
[344] Fix | Delete
*
[345] Fix | Delete
* Set display link state and EDID blob.
[346] Fix | Delete
*
[347] Fix | Delete
* The EDID blob has monitor information such as brand, name, serial
[348] Fix | Delete
* number, physical size, supported video modes and more.
[349] Fix | Delete
*
[350] Fix | Delete
* This special region allows userspace (typically qemu) set a virtual
[351] Fix | Delete
* EDID for the virtual monitor, which allows a flexible display
[352] Fix | Delete
* configuration.
[353] Fix | Delete
*
[354] Fix | Delete
* For the edid blob spec look here:
[355] Fix | Delete
* https://en.wikipedia.org/wiki/Extended_Display_Identification_Data
[356] Fix | Delete
*
[357] Fix | Delete
* On linux systems you can find the EDID blob in sysfs:
[358] Fix | Delete
* /sys/class/drm/${card}/${connector}/edid
[359] Fix | Delete
*
[360] Fix | Delete
* You can use the edid-decode ulility (comes with xorg-x11-utils) to
[361] Fix | Delete
* decode the EDID blob.
[362] Fix | Delete
*
[363] Fix | Delete
* @edid_offset: location of the edid blob, relative to the
[364] Fix | Delete
* start of the region (readonly).
[365] Fix | Delete
* @edid_max_size: max size of the edid blob (readonly).
[366] Fix | Delete
* @edid_size: actual edid size (read/write).
[367] Fix | Delete
* @link_state: display link state (read/write).
[368] Fix | Delete
* VFIO_DEVICE_GFX_LINK_STATE_UP: Monitor is turned on.
[369] Fix | Delete
* VFIO_DEVICE_GFX_LINK_STATE_DOWN: Monitor is turned off.
[370] Fix | Delete
* @max_xres: max display width (0 == no limitation, readonly).
[371] Fix | Delete
* @max_yres: max display height (0 == no limitation, readonly).
[372] Fix | Delete
*
[373] Fix | Delete
* EDID update protocol:
[374] Fix | Delete
* (1) set link-state to down.
[375] Fix | Delete
* (2) update edid blob and size.
[376] Fix | Delete
* (3) set link-state to up.
[377] Fix | Delete
*/
[378] Fix | Delete
struct vfio_region_gfx_edid {
[379] Fix | Delete
__u32 edid_offset;
[380] Fix | Delete
__u32 edid_max_size;
[381] Fix | Delete
__u32 edid_size;
[382] Fix | Delete
__u32 max_xres;
[383] Fix | Delete
__u32 max_yres;
[384] Fix | Delete
__u32 link_state;
[385] Fix | Delete
#define VFIO_DEVICE_GFX_LINK_STATE_UP 1
[386] Fix | Delete
#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2
[387] Fix | Delete
};
[388] Fix | Delete
[389] Fix | Delete
/* sub-types for VFIO_REGION_TYPE_CCW */
[390] Fix | Delete
#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1)
[391] Fix | Delete
#define VFIO_REGION_SUBTYPE_CCW_SCHIB (2)
[392] Fix | Delete
#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
[393] Fix | Delete
[394] Fix | Delete
/* sub-types for VFIO_REGION_TYPE_MIGRATION */
[395] Fix | Delete
#define VFIO_REGION_SUBTYPE_MIGRATION (1)
[396] Fix | Delete
[397] Fix | Delete
/*
[398] Fix | Delete
* The structure vfio_device_migration_info is placed at the 0th offset of
[399] Fix | Delete
* the VFIO_REGION_SUBTYPE_MIGRATION region to get and set VFIO device related
[400] Fix | Delete
* migration information. Field accesses from this structure are only supported
[401] Fix | Delete
* at their native width and alignment. Otherwise, the result is undefined and
[402] Fix | Delete
* vendor drivers should return an error.
[403] Fix | Delete
*
[404] Fix | Delete
* device_state: (read/write)
[405] Fix | Delete
* - The user application writes to this field to inform the vendor driver
[406] Fix | Delete
* about the device state to be transitioned to.
[407] Fix | Delete
* - The vendor driver should take the necessary actions to change the
[408] Fix | Delete
* device state. After successful transition to a given state, the
[409] Fix | Delete
* vendor driver should return success on write(device_state, state)
[410] Fix | Delete
* system call. If the device state transition fails, the vendor driver
[411] Fix | Delete
* should return an appropriate -errno for the fault condition.
[412] Fix | Delete
* - On the user application side, if the device state transition fails,
[413] Fix | Delete
* that is, if write(device_state, state) returns an error, read
[414] Fix | Delete
* device_state again to determine the current state of the device from
[415] Fix | Delete
* the vendor driver.
[416] Fix | Delete
* - The vendor driver should return previous state of the device unless
[417] Fix | Delete
* the vendor driver has encountered an internal error, in which case
[418] Fix | Delete
* the vendor driver may report the device_state VFIO_DEVICE_STATE_ERROR.
[419] Fix | Delete
* - The user application must use the device reset ioctl to recover the
[420] Fix | Delete
* device from VFIO_DEVICE_STATE_ERROR state. If the device is
[421] Fix | Delete
* indicated to be in a valid device state by reading device_state, the
[422] Fix | Delete
* user application may attempt to transition the device to any valid
[423] Fix | Delete
* state reachable from the current state or terminate itself.
[424] Fix | Delete
*
[425] Fix | Delete
* device_state consists of 3 bits:
[426] Fix | Delete
* - If bit 0 is set, it indicates the _RUNNING state. If bit 0 is clear,
[427] Fix | Delete
* it indicates the _STOP state. When the device state is changed to
[428] Fix | Delete
* _STOP, driver should stop the device before write() returns.
[429] Fix | Delete
* - If bit 1 is set, it indicates the _SAVING state, which means that the
[430] Fix | Delete
* driver should start gathering device state information that will be
[431] Fix | Delete
* provided to the VFIO user application to save the device's state.
[432] Fix | Delete
* - If bit 2 is set, it indicates the _RESUMING state, which means that
[433] Fix | Delete
* the driver should prepare to resume the device. Data provided through
[434] Fix | Delete
* the migration region should be used to resume the device.
[435] Fix | Delete
* Bits 3 - 31 are reserved for future use. To preserve them, the user
[436] Fix | Delete
* application should perform a read-modify-write operation on this
[437] Fix | Delete
* field when modifying the specified bits.
[438] Fix | Delete
*
[439] Fix | Delete
* +------- _RESUMING
[440] Fix | Delete
* |+------ _SAVING
[441] Fix | Delete
* ||+----- _RUNNING
[442] Fix | Delete
* |||
[443] Fix | Delete
* 000b => Device Stopped, not saving or resuming
[444] Fix | Delete
* 001b => Device running, which is the default state
[445] Fix | Delete
* 010b => Stop the device & save the device state, stop-and-copy state
[446] Fix | Delete
* 011b => Device running and save the device state, pre-copy state
[447] Fix | Delete
* 100b => Device stopped and the device state is resuming
[448] Fix | Delete
* 101b => Invalid state
[449] Fix | Delete
* 110b => Error state
[450] Fix | Delete
* 111b => Invalid state
[451] Fix | Delete
*
[452] Fix | Delete
* State transitions:
[453] Fix | Delete
*
[454] Fix | Delete
* _RESUMING _RUNNING Pre-copy Stop-and-copy _STOP
[455] Fix | Delete
* (100b) (001b) (011b) (010b) (000b)
[456] Fix | Delete
* 0. Running or default state
[457] Fix | Delete
* |
[458] Fix | Delete
*
[459] Fix | Delete
* 1. Normal Shutdown (optional)
[460] Fix | Delete
* |------------------------------------->|
[461] Fix | Delete
*
[462] Fix | Delete
* 2. Save the state or suspend
[463] Fix | Delete
* |------------------------->|---------->|
[464] Fix | Delete
*
[465] Fix | Delete
* 3. Save the state during live migration
[466] Fix | Delete
* |----------->|------------>|---------->|
[467] Fix | Delete
*
[468] Fix | Delete
* 4. Resuming
[469] Fix | Delete
* |<---------|
[470] Fix | Delete
*
[471] Fix | Delete
* 5. Resumed
[472] Fix | Delete
* |--------->|
[473] Fix | Delete
*
[474] Fix | Delete
* 0. Default state of VFIO device is _RUNNING when the user application starts.
[475] Fix | Delete
* 1. During normal shutdown of the user application, the user application may
[476] Fix | Delete
* optionally change the VFIO device state from _RUNNING to _STOP. This
[477] Fix | Delete
* transition is optional. The vendor driver must support this transition but
[478] Fix | Delete
* must not require it.
[479] Fix | Delete
* 2. When the user application saves state or suspends the application, the
[480] Fix | Delete
* device state transitions from _RUNNING to stop-and-copy and then to _STOP.
[481] Fix | Delete
* On state transition from _RUNNING to stop-and-copy, driver must stop the
[482] Fix | Delete
* device, save the device state and send it to the application through the
[483] Fix | Delete
* migration region. The sequence to be followed for such transition is given
[484] Fix | Delete
* below.
[485] Fix | Delete
* 3. In live migration of user application, the state transitions from _RUNNING
[486] Fix | Delete
* to pre-copy, to stop-and-copy, and to _STOP.
[487] Fix | Delete
* On state transition from _RUNNING to pre-copy, the driver should start
[488] Fix | Delete
* gathering the device state while the application is still running and send
[489] Fix | Delete
* the device state data to application through the migration region.
[490] Fix | Delete
* On state transition from pre-copy to stop-and-copy, the driver must stop
[491] Fix | Delete
* the device, save the device state and send it to the user application
[492] Fix | Delete
* through the migration region.
[493] Fix | Delete
* Vendor drivers must support the pre-copy state even for implementations
[494] Fix | Delete
* where no data is provided to the user before the stop-and-copy state. The
[495] Fix | Delete
* user must not be required to consume all migration data before the device
[496] Fix | Delete
* transitions to a new state, including the stop-and-copy state.
[497] Fix | Delete
* The sequence to be followed for above two transitions is given below.
[498] Fix | Delete
* 4. To start the resuming phase, the device state should be transitioned from
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function