1 /* 2 * Copyright (C) 2019 - 2020 Intel Corporation 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef _USFSTL_VHOST_PROTO_H_ 7 #define _USFSTL_VHOST_PROTO_H_ 8 9 #define MAX_REGIONS 8 10 11 // For simplicity, we only support snapshotting a fixed number of queues. Should 12 // be equal to HWSIM_NUM_VQS. 13 #define NUM_SNAPSHOT_QUEUES 2 14 15 /* these are from the vhost-user spec */ 16 17 struct vhost_user_msg_hdr { 18 uint32_t request; 19 20 #define VHOST_USER_MSG_FLAGS_VERSION 0x3 21 #define VHOST_USER_VERSION 1 22 #define VHOST_USER_MSG_FLAGS_REPLY 0x4 23 #define VHOST_USER_MSG_FLAGS_NEED_REPLY 0x8 24 uint32_t flags; 25 26 uint32_t size; 27 }; 28 29 struct vhost_user_region { 30 uint64_t guest_phys_addr; 31 uint64_t size; 32 uint64_t user_addr; 33 uint64_t mmap_offset; 34 }; 35 36 37 struct vhost_user_snapshot { 38 }; 39 40 41 struct vhost_user_msg { 42 struct vhost_user_msg_hdr hdr; 43 union { 44 #define VHOST_USER_U64_VRING_IDX_MSK 0x7f 45 #define VHOST_USER_U64_NO_FD 0x80 46 int8_t i8; 47 uint64_t u64; 48 struct { 49 uint32_t idx, num; 50 } vring_state; 51 // "A vring descriptor index for split virtqueues" 52 struct { 53 uint32_t idx, index_in_avail_ring; 54 } vring_desc_index_split; 55 struct { 56 uint32_t idx, flags; 57 uint64_t descriptor; 58 uint64_t used; 59 uint64_t avail; 60 uint64_t log; 61 } vring_addr; 62 struct { 63 uint32_t n_regions; 64 uint32_t reserved; 65 struct vhost_user_region regions[MAX_REGIONS]; 66 } mem_regions; 67 struct { 68 uint32_t offset; 69 uint32_t size; 70 #define VHOST_USER_CFG_SPACE_WRITABLE 0x1 71 #define VHOST_USER_CFG_SPACE_MIGRATION 0x2 72 uint32_t flags; 73 uint8_t payload[0]; 74 } cfg_space; 75 struct { 76 uint64_t idx_flags; 77 uint64_t size; 78 uint64_t offset; 79 } vring_area; 80 struct { 81 uint32_t transfer_direction; 82 uint32_t migration_phase; 83 } device_state_transfer; 84 struct { 85 int8_t bool_store; 86 struct vhost_user_snapshot snapshot; 87 } __attribute__((packed)) snapshot_response; 88 struct { 89 struct vhost_user_snapshot snapshot; 90 } __attribute__((packed)) restore_request; 91 } __attribute__((packed)) payload; 92 }; 93 94 #define VHOST_USER_GET_FEATURES 1 95 #define VHOST_USER_SET_FEATURES 2 96 #define VHOST_USER_SET_OWNER 3 97 #define VHOST_USER_SET_MEM_TABLE 5 98 #define VHOST_USER_SET_VRING_NUM 8 99 #define VHOST_USER_SET_VRING_ADDR 9 100 #define VHOST_USER_SET_VRING_BASE 10 101 #define VHOST_USER_GET_VRING_BASE 11 102 #define VHOST_USER_SET_VRING_KICK 12 103 #define VHOST_USER_SET_VRING_CALL 13 104 #define VHOST_USER_GET_PROTOCOL_FEATURES 15 105 #define VHOST_USER_SET_VRING_ENABLE 18 106 #define VHOST_USER_SET_PROTOCOL_FEATURES 16 107 #define VHOST_USER_SET_SLAVE_REQ_FD 21 108 #define VHOST_USER_GET_CONFIG 24 109 #define VHOST_USER_VRING_KICK 35 110 #define VHOST_USER_SET_DEVICE_STATE_FD 42 111 #define VHOST_USER_CHECK_DEVICE_STATE 43 112 #define VHOST_USER_SNAPSHOT 1002 113 #define VHOST_USER_RESTORE 1003 114 #define VHOST_USER_GET_SHARED_MEMORY_REGIONS 1004 115 116 #define VHOST_USER_SLAVE_CONFIG_CHANGE_MSG 2 117 #define VHOST_USER_SLAVE_VRING_CALL 4 118 119 #define VHOST_USER_F_PROTOCOL_FEATURES 30 120 121 #define VHOST_USER_PROTOCOL_F_MQ 0 122 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 123 #define VHOST_USER_PROTOCOL_F_RARP 2 124 #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 125 #define VHOST_USER_PROTOCOL_F_MTU 4 126 #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5 127 #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 128 #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7 129 #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8 130 #define VHOST_USER_PROTOCOL_F_CONFIG 9 131 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10 132 #define VHOST_USER_PROTOCOL_F_H_OST_NOTIFIER 11 133 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 134 #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 135 #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14 136 #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 137 138 #endif // _USFSTL_VHOST_PROTO_H_ 139