aboutsummaryrefslogtreecommitdiff
path: root/wmediumd/inc/usfstl/vhostproto.h
blob: 579af54a155d8879c8e8096c3a473123a4cc63c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * Copyright (C) 2019 - 2020 Intel Corporation
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#ifndef _USFSTL_VHOST_PROTO_H_
#define _USFSTL_VHOST_PROTO_H_

#define MAX_REGIONS 8

// For simplicity, we only support snapshotting a fixed number of queues. Should
// be equal to HWSIM_NUM_VQS.
#define NUM_SNAPSHOT_QUEUES 2

/* these are from the vhost-user spec */

struct vhost_user_msg_hdr {
	uint32_t request;

#define VHOST_USER_MSG_FLAGS_VERSION	0x3
#define VHOST_USER_VERSION		  1
#define VHOST_USER_MSG_FLAGS_REPLY	0x4
#define VHOST_USER_MSG_FLAGS_NEED_REPLY	0x8
	uint32_t flags;

	uint32_t size;
};

struct vhost_user_region {
	uint64_t guest_phys_addr;
	uint64_t size;
	uint64_t user_addr;
	uint64_t mmap_offset;
};

struct vhost_user_snapshot {
	int8_t sleeping[NUM_SNAPSHOT_QUEUES];
};

struct vhost_user_msg {
	struct vhost_user_msg_hdr hdr;
	union {
#define VHOST_USER_U64_VRING_IDX_MSK	0x7f
#define VHOST_USER_U64_NO_FD		0x80
		int8_t i8;
		uint64_t u64;
		struct {
			uint32_t idx, num;
		} vring_state;
		struct {
			uint32_t idx, flags;
			uint64_t descriptor;
			uint64_t used;
			uint64_t avail;
			uint64_t log;
		} vring_addr;
		struct {
			uint32_t n_regions;
			uint32_t reserved;
			struct vhost_user_region regions[MAX_REGIONS];
		} mem_regions;
		struct {
			uint32_t offset;
			uint32_t size;
#define VHOST_USER_CFG_SPACE_WRITABLE	0x1
#define VHOST_USER_CFG_SPACE_MIGRATION	0x2
			uint32_t flags;
			uint8_t payload[0];
		} cfg_space;
		struct {
			uint64_t idx_flags;
			uint64_t size;
			uint64_t offset;
		} vring_area;
		struct {
			int8_t bool_store;
			struct vhost_user_snapshot snapshot;
		}  __attribute__((packed)) snapshot_response;
		struct {
			struct vhost_user_snapshot snapshot;
		} __attribute__((packed)) restore_request;
	} __attribute__((packed)) payload;
};

#define VHOST_USER_GET_FEATURES			 1
#define VHOST_USER_SET_FEATURES			 2
#define VHOST_USER_SET_OWNER			 3
#define VHOST_USER_SET_MEM_TABLE		 5
#define VHOST_USER_SET_VRING_NUM		 8
#define VHOST_USER_SET_VRING_ADDR		 9
#define VHOST_USER_SET_VRING_BASE		10
#define VHOST_USER_SET_VRING_KICK		12
#define VHOST_USER_SET_VRING_CALL		13
#define VHOST_USER_GET_PROTOCOL_FEATURES	15
#define VHOST_USER_SET_VRING_ENABLE		18
#define VHOST_USER_SET_PROTOCOL_FEATURES	16
#define VHOST_USER_SET_SLAVE_REQ_FD		21
#define VHOST_USER_GET_CONFIG			24
#define VHOST_USER_VRING_KICK			35
#define VHOST_USER_GET_SHARED_MEMORY_REGIONS	41
#define VHOST_USER_SLEEP			42
#define VHOST_USER_WAKE				43
#define VHOST_USER_SNAPSHOT			44
#define VHOST_USER_RESTORE			45

#define VHOST_USER_SLAVE_CONFIG_CHANGE_MSG	 2
#define VHOST_USER_SLAVE_VRING_CALL		 4

#define VHOST_USER_F_PROTOCOL_FEATURES 30

#define VHOST_USER_PROTOCOL_F_MQ                    0
#define VHOST_USER_PROTOCOL_F_LOG_SHMFD             1
#define VHOST_USER_PROTOCOL_F_RARP                  2
#define VHOST_USER_PROTOCOL_F_REPLY_ACK             3
#define VHOST_USER_PROTOCOL_F_MTU                   4
#define VHOST_USER_PROTOCOL_F_SLAVE_REQ             5
#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN          6
#define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION        7
#define VHOST_USER_PROTOCOL_F_PAGEFAULT             8
#define VHOST_USER_PROTOCOL_F_CONFIG                9
#define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD        10
#define VHOST_USER_PROTOCOL_F_H_OST_NOTIFIER        11
#define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD       12
#define VHOST_USER_PROTOCOL_F_RESET_DEVICE         13
#define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14

#endif // _USFSTL_VHOST_PROTO_H_