1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
10 #ifndef VHOST_USER_MEMORY_MAX_NREGIONS
11 #define VHOST_USER_MEMORY_MAX_NREGIONS 8
14 #ifndef VHOST_USER_MAX_CONFIG_SIZE
15 #define VHOST_USER_MAX_CONFIG_SIZE 256
18 #ifndef VHOST_USER_PROTOCOL_F_CONFIG
19 #define VHOST_USER_PROTOCOL_F_CONFIG 9
22 #ifndef VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD
23 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12
26 #define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
28 #define VIRTIO_BLK_T_IN 0
29 #define VIRTIO_BLK_T_OUT 1
30 #define VIRTIO_BLK_T_FLUSH 4
31 #define VIRTIO_BLK_T_GET_ID 8
32 #define VIRTIO_BLK_T_DISCARD 11
33 #define VIRTIO_BLK_T_WRITE_ZEROES 13
35 #define VIRTIO_BLK_S_OK 0
36 #define VIRTIO_BLK_S_IOERR 1
37 #define VIRTIO_BLK_S_UNSUPP 2
39 enum vhost_user_request {
41 VHOST_USER_GET_FEATURES = 1,
42 VHOST_USER_SET_FEATURES = 2,
43 VHOST_USER_SET_OWNER = 3,
44 VHOST_USER_RESET_OWNER = 4,
45 VHOST_USER_SET_MEM_TABLE = 5,
46 VHOST_USER_SET_LOG_BASE = 6,
47 VHOST_USER_SET_LOG_FD = 7,
48 VHOST_USER_SET_VRING_NUM = 8,
49 VHOST_USER_SET_VRING_ADDR = 9,
50 VHOST_USER_SET_VRING_BASE = 10,
51 VHOST_USER_GET_VRING_BASE = 11,
52 VHOST_USER_SET_VRING_KICK = 12,
53 VHOST_USER_SET_VRING_CALL = 13,
54 VHOST_USER_SET_VRING_ERR = 14,
55 VHOST_USER_GET_PROTOCOL_FEATURES = 15,
56 VHOST_USER_SET_PROTOCOL_FEATURES = 16,
57 VHOST_USER_GET_QUEUE_NUM = 17,
58 VHOST_USER_SET_VRING_ENABLE = 18,
62 /** Get/set config msg payload */
63 struct vhost_user_config {
67 uint8_t region[VHOST_USER_MAX_CONFIG_SIZE];
70 /** Fixed-size vhost_memory struct */
71 struct vhost_memory_padded {
74 struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS];
77 struct vhost_user_msg {
78 enum vhost_user_request request;
80 #define VHOST_USER_VERSION_MASK 0x3
81 #define VHOST_USER_REPLY_MASK (0x1 << 2)
83 uint32_t size; /**< the following payload size */
85 #define VHOST_USER_VRING_IDX_MASK 0xff
86 #define VHOST_USER_VRING_NOFD_MASK (0x1 << 8)
88 struct vhost_vring_state state;
89 struct vhost_vring_addr addr;
90 struct vhost_memory_padded memory;
91 struct vhost_user_config cfg;