1*0b3d881aSJohn Levon #ifndef VFIO_USER_PROTOCOL_H 2*0b3d881aSJohn Levon #define VFIO_USER_PROTOCOL_H 3*0b3d881aSJohn Levon 4*0b3d881aSJohn Levon /* 5*0b3d881aSJohn Levon * vfio protocol over a UNIX socket. 6*0b3d881aSJohn Levon * 7*0b3d881aSJohn Levon * Copyright © 2018, 2021 Oracle and/or its affiliates. 8*0b3d881aSJohn Levon * 9*0b3d881aSJohn Levon * Each message has a standard header that describes the command 10*0b3d881aSJohn Levon * being sent, which is almost always a VFIO ioctl(). 11*0b3d881aSJohn Levon * 12*0b3d881aSJohn Levon * The header may be followed by command-specific data, such as the 13*0b3d881aSJohn Levon * region and offset info for read and write commands. 14*0b3d881aSJohn Levon * 15*0b3d881aSJohn Levon * SPDX-License-Identifier: GPL-2.0-or-later 16*0b3d881aSJohn Levon */ 17*0b3d881aSJohn Levon 18*0b3d881aSJohn Levon typedef struct { 19*0b3d881aSJohn Levon uint16_t id; 20*0b3d881aSJohn Levon uint16_t command; 21*0b3d881aSJohn Levon uint32_t size; 22*0b3d881aSJohn Levon uint32_t flags; 23*0b3d881aSJohn Levon uint32_t error_reply; 24*0b3d881aSJohn Levon } VFIOUserHdr; 25*0b3d881aSJohn Levon 26*0b3d881aSJohn Levon /* VFIOUserHdr commands */ 27*0b3d881aSJohn Levon enum vfio_user_command { 28*0b3d881aSJohn Levon VFIO_USER_VERSION = 1, 29*0b3d881aSJohn Levon VFIO_USER_DMA_MAP = 2, 30*0b3d881aSJohn Levon VFIO_USER_DMA_UNMAP = 3, 31*0b3d881aSJohn Levon VFIO_USER_DEVICE_GET_INFO = 4, 32*0b3d881aSJohn Levon VFIO_USER_DEVICE_GET_REGION_INFO = 5, 33*0b3d881aSJohn Levon VFIO_USER_DEVICE_GET_REGION_IO_FDS = 6, 34*0b3d881aSJohn Levon VFIO_USER_DEVICE_GET_IRQ_INFO = 7, 35*0b3d881aSJohn Levon VFIO_USER_DEVICE_SET_IRQS = 8, 36*0b3d881aSJohn Levon VFIO_USER_REGION_READ = 9, 37*0b3d881aSJohn Levon VFIO_USER_REGION_WRITE = 10, 38*0b3d881aSJohn Levon VFIO_USER_DMA_READ = 11, 39*0b3d881aSJohn Levon VFIO_USER_DMA_WRITE = 12, 40*0b3d881aSJohn Levon VFIO_USER_DEVICE_RESET = 13, 41*0b3d881aSJohn Levon VFIO_USER_DIRTY_PAGES = 14, 42*0b3d881aSJohn Levon VFIO_USER_MAX, 43*0b3d881aSJohn Levon }; 44*0b3d881aSJohn Levon 45*0b3d881aSJohn Levon /* VFIOUserHdr flags */ 46*0b3d881aSJohn Levon #define VFIO_USER_REQUEST 0x0 47*0b3d881aSJohn Levon #define VFIO_USER_REPLY 0x1 48*0b3d881aSJohn Levon #define VFIO_USER_TYPE 0xF 49*0b3d881aSJohn Levon 50*0b3d881aSJohn Levon #define VFIO_USER_NO_REPLY 0x10 51*0b3d881aSJohn Levon #define VFIO_USER_ERROR 0x20 52*0b3d881aSJohn Levon 53*0b3d881aSJohn Levon #endif /* VFIO_USER_PROTOCOL_H */ 54